[Greasemonkey] Changing HMTLTitleElement

alan taylor kokogiak at gmail.com
Mon Apr 25 16:58:42 EDT 2005


this:

document.title="My New Title";

works fine for me in a couple scripts I've done. Even works its way
into the tabs.

-Alan

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
> http://mozdev.org/mailman/listinfo/greasemonkey
> 
> 
>


More information about the Greasemonkey mailing list