-1

I am trying to replace all tags through a bookmarklet. I am ONLY using javascript. I've tried using the methods used in this link but that doesn't seem to work.

<script>
var imgs = document.getElementsByTagName("img");
for(var i=0, l=imgs.length; i<l; i++) {
imgs[i].src = "http://3.bp.blogspot.com/-KL7d7LdSANg/Tm5VLQf9k4I/AAAAAAAAACo/cSV52JoD7vk/s1600/cat-wallpaper-34-713472.jpg";
}
</script>

Is the code I was trying out. What am I doing wrong?

4

2 回答 2

4

这将是您脚本的“书签”版本

javascript:var imgs = document.getElementsByTagName("img");for(var i=0, l=imgs.length;i<l;i++){imgs[i].src = "http://3.bp.blogspot.com/-KL7d7LdSANg/Tm5VLQf9k4I/AAAAAAAAACo/cSV52JoD7vk/s1600/cat-wallpaper-34-713472.jpg";}
于 2013-10-30T21:18:39.287 回答
-2

将此代码保存在函数中,并在加载 DOM 后调用它。也许它对你有帮助。

于 2013-10-30T21:19:04.877 回答