Post by Peter on Sept 17, 2005 5:25:24 GMT -8
I think there is already a switchIt code in this database, but I believe it loops through the cells, this doesn't.
This has also been added to the support FAQ.
<script type="text/javascript">
<!--
function switchIt(item, item2){
if(!location.href.match(/=headersfooters2/i)){
if(document.createTreeWalker && typeof Node != "undefined"){
Node.prototype.switchTxt = function(r, rp){
function testNode(node){
if(node.data.match(new RegExp(r, "ig"))){
return NodeFilter.FILTER_ACCEPT;
} else {
return NodeFilter.FILTER_SKIP;
}
}
var nTree = this.ownerDocument.createTreeWalker(this, NodeFilter.SHOW_TEXT, testNode, false);
while(nTree.nextNode()){
nTree.currentNode.data = nTree.currentNode.data.replace(new RegExp(r, "gi"), rp);
}
}
document.body.switchTxt(item, item2);
} else if(typeof document.body.createTextRange != "undefined"){
var range = document.body.createTextRange();
range.collapse(true);
while(range.findText(item)){
range.text = item2;
range.collapse(false);
}
}
}
}
switchIt("Guest", "Visitor");
switchIt("Member", "User");
switchIt("Word", "Word to change to");
//-->
</script>
Simple to use, just look at the examples in the script.
Can go in header or footer, depending on what you are changing, but footer will do.
This has also been added to the support FAQ.
<script type="text/javascript">
<!--
function switchIt(item, item2){
if(!location.href.match(/=headersfooters2/i)){
if(document.createTreeWalker && typeof Node != "undefined"){
Node.prototype.switchTxt = function(r, rp){
function testNode(node){
if(node.data.match(new RegExp(r, "ig"))){
return NodeFilter.FILTER_ACCEPT;
} else {
return NodeFilter.FILTER_SKIP;
}
}
var nTree = this.ownerDocument.createTreeWalker(this, NodeFilter.SHOW_TEXT, testNode, false);
while(nTree.nextNode()){
nTree.currentNode.data = nTree.currentNode.data.replace(new RegExp(r, "gi"), rp);
}
}
document.body.switchTxt(item, item2);
} else if(typeof document.body.createTextRange != "undefined"){
var range = document.body.createTextRange();
range.collapse(true);
while(range.findText(item)){
range.text = item2;
range.collapse(false);
}
}
}
}
switchIt("Guest", "Visitor");
switchIt("Member", "User");
switchIt("Word", "Word to change to");
//-->
</script>
Simple to use, just look at the examples in the script.
Can go in header or footer, depending on what you are changing, but footer will do.