Hi there I need a javascript code which searches a specific word on the whole page and replace it with a specific page. For Example I have a page which word google and i want to replace google with Yahoo. Plz urgently needed this script. I prefer Javascript or PHP
I'm not exactly sure what you're looking for, but Javascript has regular expressions. Here's an example of how to use them: Code: <script> var re = new RegExp("google", "ig"); var s = "xxxxgooglexxxxxxxxxGOOGLExxx"; var r = s.replace(re, "yahoo"); document.write(r); </script>
hey, where r you use this? i got it. i think you r making a social networking site (i think so) and you don't want, that somebody use wrong words on your site, if it used then you can replace with any specific word. take this tut http://www.tizag.com/javascriptT/javascript-string-replace.php And code Code: <script type="text/javascript"> function searchPage(word, replaceWord, tagName){ var elems = document.getElementsByTagName(tagName); for(var i=0; i < elems.length; i++){ if(elems[i].innerHTML = word){ elems[i].innerHTML = replaceWord; } } } </script> thanks