Post by california on Jul 2, 2005 21:36:40 GMT -8
This code will allow you to replace any text or HTML code on your board with something else. Be very careful when using it. If the replacement results in an incorrect table structure or damages the structure of other tags it tends to cause "unknown runtime errors" in IE or worse, the "Operation Aborted" error. Make sure the text you're replacing is complicated enough so that it only picks it up in the spot you want it, and nowhere else. For example, don't use
switchit("karma","level");
because that will screw up the action=karma URLs. Instead you could use
switchit("Karma: ","Level: ");
the colon and the space afterwards makes it specific enough. Now for the code:
<script type="text/javascript">
<!--
/* switch-it */
var font=document.getElementsByTagName("font");
function switchit(t1,t2){
for(i=0;i<font.length;i++){
var f=font[i].innerHTML;
if(f.match(t1) && !location.href.match(/(headers|modify)/)){
font[i].innerHTML=f.replace(t1,t2);
}
}
}
switchit('<B>Topics</B>','<img src="yourhost/topics.gif" />');
switchit('on <B>Today','<B>Today');
switchit('on Yeste','Yeste');
switchit('original text/html','replacement text/html');
// -->
</script>
Footers
The part here is where you edit:
switchit('<B>Topics</B>','<img src="yourhost/topics.gif" />');
switchit('on <B>Today','<B>Today');
switchit('on Yeste','Yeste');
switchit('original text/html','replacement text/html');
these are just examples. Do not leave them in the code. Remove them and use your own. You can have as few or many switchit lines as you like. I recommend testing the code in a test board footer first before adding it to the global or main footer, that way if something does go wrong, you can still safely remove the code. The code doesn't execute on the headers/footers page in the first place so you shouldn't really have that problem.
For Advanced Users
You can use RegExp for the original text:
switchit(/some RegExp/gi,'replacement');
etc. I recommend using case-insensive matching because you never know how the browser actually handles the HTML. What you see in the source code is NOT the actual coding you're replacing. As far as the browser is concerned, if you want to see the "real" source code of the page, type this into the address bar:
javascript:'<xmp>'+document.body.innerHTML+'</xmp>';
Notice in IE, all HTML tags are made uppercase and most quote marks around attribute values are removed.
switchit("karma","level");
because that will screw up the action=karma URLs. Instead you could use
switchit("Karma: ","Level: ");
the colon and the space afterwards makes it specific enough. Now for the code:
<script type="text/javascript">
<!--
/* switch-it */
var font=document.getElementsByTagName("font");
function switchit(t1,t2){
for(i=0;i<font.length;i++){
var f=font[i].innerHTML;
if(f.match(t1) && !location.href.match(/(headers|modify)/)){
font[i].innerHTML=f.replace(t1,t2);
}
}
}
switchit('<B>Topics</B>','<img src="yourhost/topics.gif" />');
switchit('on <B>Today','<B>Today');
switchit('on Yeste','Yeste');
switchit('original text/html','replacement text/html');
// -->
</script>
Footers
The part here is where you edit:
switchit('<B>Topics</B>','<img src="yourhost/topics.gif" />');
switchit('on <B>Today','<B>Today');
switchit('on Yeste','Yeste');
switchit('original text/html','replacement text/html');
these are just examples. Do not leave them in the code. Remove them and use your own. You can have as few or many switchit lines as you like. I recommend testing the code in a test board footer first before adding it to the global or main footer, that way if something does go wrong, you can still safely remove the code. The code doesn't execute on the headers/footers page in the first place so you shouldn't really have that problem.
For Advanced Users
You can use RegExp for the original text:
switchit(/some RegExp/gi,'replacement');
etc. I recommend using case-insensive matching because you never know how the browser actually handles the HTML. What you see in the source code is NOT the actual coding you're replacing. As far as the browser is concerned, if you want to see the "real" source code of the page, type this into the address bar:
javascript:'<xmp>'+document.body.innerHTML+'</xmp>';
Notice in IE, all HTML tags are made uppercase and most quote marks around attribute values are removed.