如何在iframe
页面中查找特定单词?
我无法控制 iframe
页面,因此所有代码都必须放置在父页面中。
这是在父页面中查找单词的代码
init();
function init()
{
searchWord("exgirlfriend");
}
function searchWord(word)
{
var pageResults = document.body.innerHTML.match(word);
if(pageResults)
{
alert("word found");
}
}
最佳答案
由于同源政策,您无法访问来自其他域的 iframe 内容。
关于javascript - 如何使用 javascript 在 Iframe 页面中查找特定单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7181383/