Show title on page

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Is there a way to insert the page's title in the middle of the text of the
page. For example: "Do you want to read other articles about <INSERT TITLE
HERE>? Then, check out:" <INSERT CHILD LEVEL NAVIGATION HERE>?

Thanks.
Michael
 
The only way I can think of to reuse the contents of the page's <title> tag
would be to use some javascript to define a variable, and then
document.write() both the title tag containing that variable, as well as the
second use of it in the body of the page.
 
You don't even have to define a variable. The title is already known to JS
e.g
Do you want to read other articles about <script
type="text/javascript">document.write(document.title)</script>?
Then, check out:" <INSERT CHILD LEVEL NAVIGATION HERE>?

The second title you will have to insert yourself. In fact , you would
probably use a link
e.g.
Then, check out <a href="page2.html">Page 2 Title</a>
 
I thought sure that was available but couldn't find it. Of course, now that
you have mentioned it, I did! Thanks, Trevor.
 
Very cool and simple! Thanks!

Any way to put that in an iFrame and have it return the title of the main
page and not just the title of the iFrame?

Thanks again!

Michael
 
In addition to putting it in an iFrame, is it possible to have it indicate
something other than the title? For example, all of my titles are "article
name + website name" while my NAVIGATION titles are just "article name"
(w/the website's url). I'd prefer my little blurb not say, "Want to learn
more about ABC - www.MissionePerTe.it" and just say, "Want to learn more
about ABC" (where ABC is my Navigation title). Am I just dreaming here?
Michael
 
Hey Trevor! 8)

--
Murray



Michael said:
In addition to putting it in an iFrame, is it possible to have it indicate
something other than the title? For example, all of my titles are
"article
name + website name" while my NAVIGATION titles are just "article name"
(w/the website's url). I'd prefer my little blurb not say, "Want to learn
more about ABC - www.MissionePerTe.it" and just say, "Want to learn more
about ABC" (where ABC is my Navigation title). Am I just dreaming here?
Michael
 
Replies in -line

Michael said:
In addition to putting it in an iFrame, is it possible to have it indicate
something other than the title? For example, all of my titles are
"article
name + website name" while my NAVIGATION titles are just "article name"
(w/the website's url). I'd prefer my little blurb not say, "Want to learn
more about ABC - www.MissionePerTe.it" and just say, "Want to learn more
about ABC" (where ABC is my Navigation title). Am I just dreaming here?
Michael

I assume that an example of "article name + website name" is
ABC - www.MissionePerTe.it

Are all these separated by ' - ' , i.e. blank, -, blank ?
If so, search for it and extract everything before this string

For example
var test = 'ABC - www.MissionePerTe.it' ;
var newstr = test.substr(0,test.indexOf(' - ')) ;
alert(newstr)

This alert returns ABC, but you would probably need to put this in a
function to which you pass the title
e.g.
<html>
<head>
<title>ABC - www.MissionePerTe.it</title>
<script type="text/javascript">
function gettitle(title,id) {
document.getElementById(id).innerHTML = title.substr(0,title.indexOf(' -
'));
}
</script>
</head>
<body>
Want to learn more about <span id="id1"></span> ?
<script type="text/javascript">gettitle(document.title, "id1")</script>
</body>
</html>

This writes the title up to ' - ' into the <span> element with id= "id1"

If in an iframe use window.top.document.title
 
Back
Top