javascript - 通过 DOM 加载页面搜索

标签 javascript jquery html dom

假设我的浏览器中加载了一个网络聊天应用程序(外部)。与所有聊天一样,您会收到有关某些事件的通知,例如新消息。 聊天会更新聊天的 DOM 以反射(reflect)这一点。

我想要实现的是通过搜索此 DOM 以查找特定事件(即 newmessage= 1),我可以使用该信息在我拥有的网页上触发警报(DOM 更新)。

我看过使用脚本获取/加载内容/url 的示例,但我猜这会获取页面的新实例,但这不是我需要的。

简单来说。我有一个 Web 应用程序,它可以显示(在单独的 div 中)一个包含另一个不是我的聊天的 iframe。人们可以将 View 切换到我的聊天和其他人。我想在查看自己的聊天时收到来自其他聊天的新消息提醒。

我希望我问的有点清楚。 ;-)

我正在使用 PHP、Javascript/Jquery 进行我自己的聊天。

最佳答案

这会违反 same origin policy :

In computing, the same-origin policy is an important concept in the web application security model. The policy permits scripts running on pages originating from the same site – a combination of scheme, hostname, and port number1 – to access each other's DOM with no specific restrictions, but prevents access to DOM on different sites.

关于javascript - 通过 DOM 加载页面搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24594280/

相关文章:

javascript - 通过 getJSON 将 JSON 加载到变量中

javascript - 每次单击按钮都需要再单击一次才能取消

jquery - Sublime Text 浏览器预览,JQuery 未运行

javascript - 如何制作灯泡菜单?

javascript - 通过类名获取内容 javascript

javascript - 为什么 Google Calendar API 的 'Free/Busy' 时间返回 'Undefined' ?

javascript - 数据表:删除行而不影响 "(filtered from X total entries)"

python - 如何抓取 - 跨 aria-hidden ="true"- 文本

html5 视频标签不播放 mp4 - IIS

javascript - JsFiddle 中的代码不起作用