Skip to content

Instantly share code, notes, and snippets.

@redforest
Created November 9, 2011 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redforest/1351716 to your computer and use it in GitHub Desktop.
Save redforest/1351716 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
function replaceImgSrc(id){
var target_hostname = 'www.baidu.com';
var imgs = document.getElementById(id).getElementsByTagName('img');
var my_hostname = window.location.hostname.toString();
for(var i=0; i<imgs.length; i++){
imgs[i].src = imgs[i].src.replace(my_hostname, target_hostname);
}
}
window.onload = function() {
replaceImgSrc('data');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment