Reputation:
I've had help from StackOverflow to generate this JavaScript to use in a GreaseMonkey script, which replaces an image with an H1 tag, to use on an Oracle E-Business Suite system where the instance name is held in an H1 tag:
// current page
var url_loc = window.location.href;
if (url_loc.indexOf("http://this.site:0123") == 0) { var env_label = "LIVE";}
if (url_loc.indexOf("http://this.site:1234") == 0) { var env_label = "TEST1";}
if (url_loc.indexOf("http://this.site:2345") == 0) { var env_label = "TEST2";}
if (url_loc.indexOf("http://this.site:3456") == 0) { var env_label = "TEST3";}
if (url_loc.indexOf("http://this.site:4567") == 0) { var env_label = "TEST4";}
if (url_loc.indexOf("http://this.site:5678") == 0) { var env_label = "TEST5";}
var imgs=document.getElementsByTagName('img');
for(var i=imgs.length-1;i>=0;i--){
if(imgs[i].title == 'NEW_UNI_LOGO.png' || imgs[i].title == 'Oracle') {
var h1 = document.createElement('h1');
h1.innerHTML = env_label;
imgs[i].parentNode.insertBefore( h1, imgs[i] );
imgs[i].parentNode.removeChild(imgs[i]);
h1.style.color = "red";
}
}
It would be really useful to also update the Title tag on the page to start with the env_label value. I don't want to replace all of the content of the Title tag, so that e.g. if the Title is:
<title>Oracle Applications Home Page</title>
I'd like to change it to e.g. for the Live Site:
<title>LIVE: Oracle Applications Home Page</title>
Basically just append env_label to the start of whatever is held in the title tag.
Thanks
Upvotes: 1
Views: 505
Reputation: 1838
Try this..
document.title = "Oracle Applications Home Page";
Appending the label to the title..
document.title =env_label + ": Oracle Applications Home Page";
Upvotes: 4
Reputation: 4833
Did you even try something before asking to it ? I can't think about a more simple problem ...
document.title = env_label + ": " + document.title;
Upvotes: 0