Greasemonkey simple html text replacing not working

那年仲夏 提交于 2019-12-10 12:04:50

问题


I need to replace all the olds links of an HTML page by the new web page so I created the following script

document.body.innerHTML.replace('www.forumoldpage','www.forumnewpage');

Save it but when I open the web page do nothing.

There's something wrong with the code or do I forgot something to do?


回答1:


I was led to this question when trying to create my very first greasemonkey script, so I thought it's for the benefit of everybody if this question has an answer. Try this:

document.body.innerHTML = document.body.innerHTML.replace('www.forumoldpage','www.forumnewpage');

replace gives you a new string with the replacement effected, but you still have to replace the contents of the web page.



来源:https://stackoverflow.com/questions/26738467/greasemonkey-simple-html-text-replacing-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!