Replace function only works once (javascript)

wherse

New Member
I need to replace a string (str1) with another string (str2) every time str1 shows in a specific div. This is what I got so far\[code\]<script type="text/javascript"> $(window).load(function(){var str=document.getElementById("foo").innerHTML; var n=str.replace("Google","Yahoo");document.getElementById("foo").innerHTML=n;}); </script>\[/code\]and the html\[code\]<div id="foo">Google is the best website ever <br />Google is not the best website ever</div>\[/code\]Unfortunately, when I run it, it only replaces the first instance of the word Google. What am I doing wrong? What do I need to add to make it replace ALL the instances of the word?
 
Back
Top