Browser tab custom title not staying

tspitalnick2
Kilo Contributor

Hi all,

I was trying to set the browser tab title to something other than "ServiceNow" when I have a custom UI page loaded. I followed Re: Dynamic Browser Window Title - Take 2 as well as a few other community posts to try to do this.

Results were that the tab would change the title to my custom one, but once I clicked any other tab, it went back to the default "ServiceNow" title. Any ideas how to override the override?

Thank you.

8 REPLIES 8

Please deactivate that UI script and try with what i have suggested or if it still doesn't work out, Please share the UI script here.



Thanks


Gaurav


Toby, I don't think Guarav read what you wrote.



ServiceNow is definitely clobbering the document.title when the tab loses focus to another tab that is looking at the same instance. I haven't found the code that's causing it yet either, so I have opened an incident with ServiceNow.



Nor do I know how to write a script that will execute only when a tab loses focus. Is there an event for that in html?


Here I've brute forced it so that the custom title is refreshed every 2 seconds:



var custom_title = "whatever";



function set_the_title() {


  window.setTimeout(function() {


  window.parent.document.title=custom_title;


      set_the_title();


  },2000);


}



set_the_title();


DustinSpain
Giga Contributor

I had a need to change the title of a UI page too.  I tried several things including the code above (document.title = "Custom title";), but that did not work either.

I was able to get it to work by putting the following code in the <head> tags:

<script>
top.document.title = "My New Title";
</script>