[Greasemonkey] Changing HMTLTitleElement

jason brackins j-san at j-san.net
Mon Apr 25 16:18:34 EDT 2005

document.title does the trick (window.title doesn't seem to work, however).

I thought if it was possible it'd be something obvious that I was just 
not seeing.
Jason Brackins

[Aaron Boodman] said on [04/25/2005 2:52 PM]

>I think either window.title = "foo" or document.title = "foo" might work better.
>On 4/25/05, jason brackins <j-san at j-san.net> wrote:
>> Hi all,
>> I am trying to change the title of the page my script is running in. The
>>page in question is a wiki and it puts the least specific info first in the
>>title element. So you might have "Wiki Site Name - Current Page name" as the
>>title. Since I tend to have 10-15 tabs opened when I'm using this particular
>>wiki it would be really nice to swap the two parts.
>> It's easy to do if you just want the change reflected in the DOM (as viewed
>>with the DOM inspector). But the change never makes it to the title bar of
>>the window (and therefor not the tab label). 
>> I'm not sure if what I'm trying to do is even possible. After all, the
>>label on the window picks up the Title element and sets itself long before
>>the page finishes loading. Since the window label is outside of the DOM the
>>javascript can't get to it directly. I was hoping Firefox would notice the
>>change in the DOM and react accordingly, but no joy. Anybody have any ideas?
>> thanks.
>> ---
>> btw, using FF 1.0.3, Greasemonkey 0.2.6, windows 98
>> my code looks like this:
>> function changeTitle() {
>> var ptitle = document.getElementsByTagName("title")[0];
>>     var titleComponents = ptitle.innerHTML.split(' - ');
>>     ptitle.textContent = titleComponents[1]+' - '+titleComponents[0];    
>> }
>>Jason Brackins 
>>Greasemonkey mailing list
>>Greasemonkey at mozdev.org
>Greasemonkey mailing list
>Greasemonkey at mozdev.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050425/72fc22d3/attachment-0001.htm

More information about the Greasemonkey mailing list