Is there a way to change every occurrence of a word into another word. For example, you have the Javascript code at the top of the page that changes the word "brown" to "red". The sentence in the page is: The quick brown fox. But with the Javascript code, it displays like this: The quick red fox. I know there is a way to do this with Java (its basically how contextual link ad services like Kontera work), I just don't know how do it.
Yes there is depends if you have that in a variable. example basics taken from php.net manual http://ca.php.net/manual/en/function.preg-replace.php <?php $str = "The quick brown fox"; echo preg_replace("/brown/", "red", $str); ?> PHP:
You could use str_replace in PHP aswell. Javascript can work with strings, but I am not 100% sure wether JS posses the ability to search through a whole page.