I'm too late for the party, but hope this helps someone else.
Your code is perfect, it just needs text to work and a way to feedback it, so this is what I would like to do, mind you, I'm not an expert, but just a violinist.
<script type="text/javascript"> //added "str" as a function input/parameter function change_url(str) { /* removed this var str = ''; */ /* changed this str = to this */ return str.replace(/blog\.domain\.info/g, 'blogtest\.domain\.info'); } //and called it like this document.onload = function(){ document.getElementsByTagName('head')[0].outerHTML = change_url(document.getElementsByTagName('head')[0].outerHTML); } </script>
And if you want to change all the links to the entire document, then you would simply call it that.
document.onload = function(){ document.getElementsByTagName('head')[0].outerHTML = change_url(document.getElementsByTagName('head')[0].outerHTML); document.getElementsByTagName('body')[0].outerHTML = change_url(document.getElementsByTagName('body')[0].outerHTML); }
This will change the entire link to blog.domain.info in src, href, img and any instance found in !! TEXT !!. So be careful when using it, because all of the above links will be changed. ; ABOUT)
user11613276
source share