Greasemonkey简单的HTML文本替换不起作用 [英] Greasemonkey simple html text replacing not working
问题描述
我需要用新网页替换HTML页面的所有旧链接,以便创建以下脚本:
document.body.innerHTML.replace( 'www.forumoldpage', 'www.forumnewpage');
保存它,但是当我打开网页时,什么都不做。
代码有问题或者我忘记了什么? 当试图创建我的第一个grepmonkey脚本的时候有问题,所以如果这个问题有答案,我认为这对每个人都有好处。试试这个:
document.body.innerHTML = document.body.innerHTML.replace('www.forumoldpage','www。 forumnewpage');
替换
会为您提供新的字符串替换受到影响,但您仍然需要更换网页的内容。
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?
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.
这篇关于Greasemonkey简单的HTML文本替换不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!