开发者

How to replace an image with another using a script?

Is there a script that allows me to replace an image on a webpage (not my site) but without editing the HTML itself. For example, the image orange.png appears twice on that page, but I need a script that looks for orange.png and automatically replaces it by the image I want. Another开发者_如何学Go example would be replacing the Google logo to use your own, but it isn't really replaced, it just appears to be. The image is not defined by css, it's in a div, and does not have an ID. Any ideas?


I don't know of any that exist...you could do PHP but that would change the HTML output. The only other way would be to use Javascript and load the whole document and try and find it...I could do something similar in PHP but not in Javascript yet...I would assume a JQuery start-off approach could be something like:

var wholesite = $(document).html()//gets the html
///then code to find and replace orange.png....


You should use User JS, I guess.

JS snippet that replaces image with "mine" ID to http://path.to/your/image.png: document.getElementById("mine").src = "http://path.to/your/image.png"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜