开发者

Greasemonkey Script to Change img tag with a applet tag

I have tried all the combinations in my little OOP brain of trying to figure out how to use Greasemonkey to replace a < img > tag with a < applet > tag.

There is a little logo down at the bottom of 开发者_如何学运维a webpage and I am trying to make a little animation with JAVA depending on some variables. I can get it above and below where I need it to be but I can't seem to replace the whole tag. I have replaced the img with another one, but I can't figure out how to change to a different tag.

I think I have figured out about 40 ways not to do it. I don't know javascript well, I'm in the Dark!


You can use the .replaceChild(oldChild, newChild) method, from the parent Node.

E.g. html:

<div>
  <img src="myimage.jpg" id="replaceMe">
</div>

greasemonkey:

var image = document.getElementById("replaceMe");
var myApplet = //however you're creating your applet Element

image.parent.replaceChild(image, myapplet);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜