Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Accessing <title> through JavaScript

Reply
Thread Tools

Accessing <title> through JavaScript

 
 
Don G
Guest
Posts: n/a
 
      02-16-2005
Is is possible to access the <title> element using JavaScript? In my
HTML, I have:

<title id="bob"></title>

and in my JavaScript I have:

bobtext = "test";

document.getElementById('bob').innerHTML = bobtext;

I am using similar code elsewhere to change a caption, but it doesn't
work here. So, is it just not allowed to modify <title> in this way, or
am I doing something wrong?

Thanks,

Don
 
Reply With Quote
 
 
 
 
Lauri Raittila
Guest
Posts: n/a
 
      02-16-2005
in alt.html, Don G wrote:
> Is is possible to access the <title> element using JavaScript? In my
> HTML, I have:
>
> <title id="bob"></title>


VEry bad idea. What if JS is disabled?

> and in my JavaScript I have:
>
> bobtext = "test";
>
> document.getElementById('bob').innerHTML = bobtext;
>
> I am using similar code elsewhere to change a caption, but it doesn't
> work here. So, is it just not allowed to modify <title> in this way, or
> am I doing something wrong?


Title can't have id in HTML. To tell more, tell your
URL
Browsers you used to test
and post to javascript group. They might actually know how to do it.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
 
Reply With Quote
 
 
 
 
jen_designs@hotmail.com
Guest
Posts: n/a
 
      02-16-2005
use the following:

myVar = "MyTitle"
document.title= myVar

 
Reply With Quote
 
Don G
Guest
Posts: n/a
 
      02-16-2005
> VEry bad idea. What if JS is disabled?

Well, then, my site would be pretty useless anyway. It's a collection
of picture galleries that use JavaScript to change the picture. If
JavaScript is disable, no pictures.

I don't suppose anyone has an idea of how do this without JS. I might
be able to do it with a CSS rollover, but I've heard that doesn't work
very well in IE. I'm also lazy, so I don't want to have to do a ton of
coding to put more pictures up.

Thanks for the advice,

Don
 
Reply With Quote
 
Lauri Raittila
Guest
Posts: n/a
 
      02-16-2005
in alt.html, Don G wrote:
> > VEry bad idea. What if JS is disabled?

>
> Well, then, my site would be pretty useless anyway. It's a collection
> of picture galleries that use JavaScript to change the picture. If
> JavaScript is disable, no pictures.


So, it is not bad idea, because you have already done much bigger
mistake...

> I don't suppose anyone has an idea of how do this without JS.


http://www.porjes.com/butterflies/in...p?butterfly=01

> I might be able to do it with a CSS rollover, but I've heard that doesn't
> work very well in IE.


The problem is that you started wrong end. First make things work whitout
JS, then you may add some.

> I'm also lazy, so I don't want to have to do a ton of
> coding to put more pictures up.


Then do everything automagically. There is image gallery software
everywhere...

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
 
Reply With Quote
 
Don G
Guest
Posts: n/a
 
      02-17-2005
> So, it is not bad idea, because you have already done much bigger
> mistake...


Well, maybe so. I made my mistake our of ignorance. I didn't really
want to do it with JS, but I didn't know of another way.

> http://www.porjes.com/butterflies/in...p?butterfly=01


Excellent page. Now I just need to figure out how it is done.

> The problem is that you started wrong end. First make things work whitout
> JS, then you may add some.


How should I have started?

I guess I don't understand the purpose of JS. If you can do something
without JS, why would you add it?

> Then do everything automagically. There is image gallery software
> everywhere...


Again, ignorance. I didn't know that such software was available. Are
these programs flexible enough that you still have full control over
what the page will look like?

Thanks for your help,

Don

 
Reply With Quote
 
Lauri Raittila
Guest
Posts: n/a
 
      02-17-2005
in alt.html, Don G wrote:
> > So, it is not bad idea, because you have already done much bigger
> > mistake...

>
> Well, maybe so. I made my mistake our of ignorance. I didn't really
> want to do it with JS, but I didn't know of another way.
>
> > http://www.porjes.com/butterflies/in...p?butterfly=01

>
> Excellent page.


Too bad that the ultimate brucie is not around anymore. I hope he will be
back sometime

> Now I just need to figure out how it is done.


There is source code. Uses PHP.

> How should I have started?


Deciding what processing to use before your HTML leaves your server.

> I guess I don't understand the purpose of JS. If you can do something
> without JS, why would you add it?


Because you can do things with it that
a) make things easier/faster for those that have it
b) to do stuff that is not possible whiout.

And yes, with these criters, most JS around is bad usage.

> > Then do everything automagically. There is image gallery software
> > everywhere...

>
> Again, ignorance. I didn't know that such software was available. Are
> these programs flexible enough that you still have full control over
> what the page will look like?


Some are. I have used JAlbum. The default templates are horrible, like in
most image gallery software.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Utrecht, NL.
 
Reply With Quote
 
nice.guy.nige
Guest
Posts: n/a
 
      02-17-2005
While the city slept, Don G ((E-Mail Removed)) feverishly typed...

> Is is possible to access the <title> element using JavaScript?

[...]

http://www.nigenet.org.uk/bits-n-bobs/changeTitle/

This is an example I knocked up a while ago for someone who wanted to change
the parent title in a frameset, which you could adapt to your needs. Note
that it won't work in NN4.x as that browser treats the title as read-only,
and -- of course -- it won't work without javascript! You may also want to
rethink what you are doing anyway as others have said. For a javascript
image gallery which also works without javascript you may want to look at
http://www.nigenet.org.uk/stuff/thumbtastic/ which uses PHP to "reload" the
page with the chosen picture if javascript is not available, otherwise it
uses javascript to change the main image and (attempt to) change the alt
text.

Hope that helps.

Cheers,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. http://www.velocityreviews.com/forums/(E-Mail Removed), take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!


 
Reply With Quote
 
Don G
Guest
Posts: n/a
 
      02-17-2005
>>Now I just need to figure out how it is done.
>
> There is source code. Uses PHP.


Ok, I guess I need to learn how to use PHP.

>>How should I have started?

>
> Deciding what processing to use before your HTML leaves your server.


Well, when I started this, I didn't have the option for server
preprocessing. Now I do, so I'll rework it.

> Because you can do things with it that
> a) make things easier/faster for those that have it
> b) to do stuff that is not possible whiout.


Ok, so I may still be able to use what I have, but I will need to work
out a PHP option for those who don't use JS.

> Some are. I have used JAlbum. The default templates are horrible, like in
> most image gallery software.


Thanks, I'll take a look t JAlbum.

Don
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      02-17-2005
Don G wrote:

> Ok, so I may still be able to use what I have, but I will need to work
> out a PHP option for those who don't use JS.


Combination PHP and Javascript:
http://examples.tobyinkster.co.uk/bestgallery/

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing pseudo-classes through Javascript (Jscript) pochartrand Javascript 37 06-14-2006 07:33 PM
Accessing SQL Server 2000 through Cisco VPN Client disaia@earthlink.net Cisco 3 03-07-2005 12:26 PM
Adding items to listbox through java script then accessing through asp.net Brian Henry ASP .Net 5 08-03-2004 02:10 AM
Accessing HTML Control in ASCX through JavaScript George Durzi ASP .Net 1 12-19-2003 05:14 PM
Accessing LAN from the page through Web Service JP ASP .Net 1 08-20-2003 01:45 PM



Advertisments