javascript - 如何使用 javascript 在 Iframe 页面中查找特定单词?

标签 javascript iframe find cpu-word

如何在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/

相关文章:

JavaScript 与基金会冲突

javascript - 代码在 Firefox 中不起作用,而在 chrome 中运行良好

javascript - 当 iframe 加载并更改其源时显示加载符号?

python - 在视频中的对象上创建边界框

linux - 使用 sed 运行 Linux find 命令时出错

javascript - 在javascript中从输入类型数组创建json

javascript - isNaN() 对于以数字开头的任何内容都会返回 false,即使它包含字母

ios - 使用 ios 浏览器在 iframe 中重定向会卡住 Phaser Canvas

html - DIV 样式使得包含的 IFRAME 不需要滚动

linux - 'find . -ls' 的输出格式是什么?