[Javascript] Setting title of web page

David Hucklesby davidh126 at writeme.com
Mon May 12 22:46:40 CDT 2008


On Sun, 11 May 2008 19:04:37 -0500, Skip Evans wrote:
> Hey all,
>
> At the suggestion of another list member this was the simplest solution:
>
> document.title="new title";
>
> Adam Fahy wrote:
>> Skip Evans wrote:
>>> So anyway, I can get the title by tag name:
>>>
>>> var title=document.getElementsByTagName('title');
>>>
>>> But I can't find the right arguments to pass to
>>>
>>> setAttribute('?????','New Page Title');
>>>

That's very odd. The title attribute is usually used for displaying
a "tooltip" in compliant browsers, and for distinguishing style sheets.
It seems counter-intuitive to me for this to alter the actual content
of the page title.

I would have thought something like this :

  document.getElementsByTagName('title')[0].firstChild = 'New Title';

(Assuming you really can access the TITLE element in all browsers.)

Cordially,
David
--





More information about the Javascript mailing list