Google Answers Logo
View Question
 
Q: Need to copy page title and push into heading tag in a .html page (includes ok) ( No Answer,   2 Comments )
Question  
Subject: Need to copy page title and push into heading tag in a .html page (includes ok)
Category: Computers > Programming
Asked by: dreamzdb-ga
List Price: $25.00
Posted: 23 Oct 2006 14:01 PDT
Expires: 04 Nov 2006 12:34 PST
Question ID: 776146
I would like to find a way to pull the <title> tag off of an html
document and use that for the content of an <h1>.  The catch is, I
want this to be printed into an HTML file and not a dynamic page. 
Using includes would be fine but the page extension has to remain
.html (no .php, .net, .jsp etc).

I'm including a javascript snippet of what I want to happen below.  I
am not using javascript however, because I want the content to actual
static, spiderable content.

var name = document.title;
function setTitle(){
var sethead = document.getElementsByTagName('h1')[0].childNodes[0].firstChild.nodeValue
= name;
}

Clarification of Question by dreamzdb-ga on 29 Oct 2006 12:47 PST
I think a combination of an Apache SSI and perl scripting might solve
my problem. However I have little experience w/ each of those and I'm
not sure how to go about it. I want to avoid changing the file
extension to support a server side language.

Clarification of Question by dreamzdb-ga on 04 Nov 2006 12:34 PST
Could I use python to copy the title of an html document and print it
into an h1 tag? If so.. how?
Answer  
There is no answer at this time.

Comments  
Subject: Re: Need to copy page title and push into heading tag in a .html page (includes ok)
From: pmmbala1976-ga on 24 Oct 2006 15:05 PDT
 
Hi

I am not sure this is what u need. got it from one of the forum.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title> </title>
<script type="text/javascript">
function changeTitle(foo){
var idToUse = foo;

// The key to it all
document.title = document.getElementById(idToUse).innerHTML;
}
</script>
</head>
<body onload='changeTitle("newTitle")'>

<h1 id="newTitle">This Is The Title2222</h1>

</body>
</html>

Thanks
Bala
Subject: Re: Need to copy page title and push into heading tag in a .html page (includes
From: dreamzdb-ga on 29 Oct 2006 11:43 PST
 
Bala-

Sorry I didn't get back to you sooner, I thought they would email me
when I had a response :).  The code that you included does exactly
what my current code does only in reverse.  The code snippet that you
gave writes the title based on the content of the h1.

Unfortunately that doesn't work for me because it's javascript and it
won't be spidered as I mentioned in my request.  Thanks for looking. 
Let me know if you find anything else out.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy