Home > Net >  Adding event handlers to dynamically created iframes through a content script
Adding event handlers to dynamically created iframes through a content script

Time:06-29

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?

CodePudding user response:

Solved: Just needed to set "match_about_blank": true in the manifest.

  • Related