If you are seeing this message, it is possible the page did not load properly. Please hit reload/refresh on your browser.
If you still see this message, you probably do not have a browser that supports web standards, although its content is accessible to any browser or Internet device.

Cool Tips & Tricks Cool Tips & Tricks

Help Communities:
Help Forums Bug Base
<< Prev Topic | Next Topic >>
Cool Tips & Tricks ::: Javascript FAQ ::: General Text Replacement Script
New Topic    Add Reply
Topic: General Text Replacement Script  (?)  Click to receive email notification of replies Click to stop receiving email notification of replies email this topic to a friend
chrish18

Registered User
ezSupporter
Posts: 2109
Posted: 7/5/05 6:53 am    
General Text Replacement Script
There are various scripts floating round the faq's that perform text replacements (eg replace "Join Live Chat!" or "Registered Members" etc) but mostly they are Internet Explorer specific. This script is a general text replacement script that can be used to change pretty much any text on your board. It comes in two parts:

Put this in Box 1
  
<script type="text/javascript">
/**
   text replacement script written by chrish18
   do not remove this notice!
*/
function searchAndReplace (collection, replaceWhat, replaceWith)
{
   for (c = 0; c < collection.length; c++)
   {
      for (n = 0; n < collection[c].childNodes.length; n++)
      {
         if (collection[c].childNodes[n].nodeType == 3)
         {
            collection[c].childNodes[n].data = collection[c].childNodes[n].data.replace(replaceWhat, replaceWith);
         }
      }
   }
}

function replaceText (replaceWhat, replaceWith)
{
   var oTD = document.getElementsByTagName("td");
   var oSpan = document.getElementsByTagName("span");
   var oLink = document.getElementsByTagName("a");
   var oDiv = document.getElementsByTagName("div");
   var oP = document.getElementsByTagName("p");
   var oFont = document.getElementsByTagName("font");
   var oStrong = document.getElementsByTagName("strong");
   var oB = document.getElementsByTagName("b");
   var oI = document.getElementsByTagName("i");
   var oEm = document.getElementsByTagName("em");
   
   var re = new RegExp(replaceWhat, "ig");
   searchAndReplace(oTD, re, replaceWith);
   searchAndReplace(oSpan, re, replaceWith);
   searchAndReplace(oLink, re, replaceWith);
   searchAndReplace(oDiv, re, replaceWith);
   searchAndReplace(oP, re, replaceWith);
   searchAndReplace(oFont, re, replaceWith);
   searchAndReplace(oStrong, re, replaceWith);
   searchAndReplace(oB, re, replaceWith);
   searchAndReplace(oI, re, replaceWith);
   searchAndReplace(oEm, re, replaceWith);
   
   return;
}
</script>
Then put this inBox 4
  
<script type="text/javascript">
replaceText("My Control Center", "My CP");
replaceText("ezNutrocker", "Super Don");
replaceText("Logged in as", "Posting as");
replaceText("Registered Members", "Crazy Posters");
replaceText("chrish18", "Chris");
replaceText("Join Live Chat!","Get Chatting");
</script>
You can add as many replaceText("replace what", "replace with") as you like between script tags.

The script has been tested with the following browsers / os

PC - Internet Explorer 6
PC - Firefox
PC - Mozilla
Mac - Safari
Mac - Firefox

(Thanks to atlass for the Mac testing :))

If you find any bugs please come back to CTT and let us know :)

Edited by: ezNutrocker at: 7/5/05 3:15 pm

  reply to this message

Click to receive email notification of replies Click to stop receiving email notification of replies email this topic to a friend

New Topic    Add Reply

jump to:
Topic Control Image::: Topic Commands
<< Prev Topic | Next Topic >>

Icon Legend

reply button:::Reply to Post Button   edit button:::Edit Post Button  delete button:::Delete Post Button (Moderator Only)

subscribe/unsubscribe to thread button:::Subscribe to Thread Button   email to friend button:::Email to Friend Button  



- Cool Tips & Tricks - Javascript FAQ -

Communitiesezboard Help Communities:

Help Forums Help Forums Bug Base Bug Base





Powered By ezboard® Ver. 7.32
Copyright ©1999-2007 ezboard, Inc.