<script type="text/javascript"> function replaceScript() { var toReplace = 'http://google.com'; var replaceWith ='http://yahoo.com'; document.body.innerHTML = document.body.innerHTML.replace(toReplace, replaceWith); } </script>
Then initialize the body tag to load the page.
<body onload="replaceScript();">
It should work fine and replace all instances in the html body code.
If it is in an iframe with the identifier "external_iframe", you should change document.body.innerHTML as:
window.frames['external_iframe'].document.body.innerHTML
Although I'm not sure that you can use it for an external site.
There seems to be some info here: Javascript Iframe innerHTML
source share