通过内容脚本将事件处理程序添加到动态创建的IFRAME
我有一个Firefox扩展程序,通过内容脚本将事件侦听器添加到网站上的所有元素中:
document.addEventListener('click', function eventHandler(e) {
// do something
})
在大多数情况下,这可以正常工作,但是当单击动态创建的IFRAMES中的元素时,EventHandler函数并未触发,例如就在 https://www.deepl.com/contact-us?cta=whydeepl = https:/ /a>
“ all_frames”:清单中的true标志已设置,并且配置为匹配所有URL,因此不应该是问题。
有没有办法使它起作用?
I have a Firefox extension that adds event listeners to all elements on a website through a content script:
document.addEventListener('click', function eventHandler(e) {
// do something
})
This works fine in most cases, but the eventHandler function is not triggered when clicking on elements in dynamically created iframes, for example, the form on the right on https://www.deepl.com/contact-us?cta=whydeepl
The "all_frames": true flag in the manifest is set, and it is configured to match all URLs, so that shouldn't be the issue.
Is there a way to get this to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:只需要在清单中设置“ match_about_blank”:true。
Solved: Just needed to set "match_about_blank": true in the manifest.