Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
Content Script not injected correctly to nested iframes in chrome extension

I am developing chrome extension accordingly, one of the requirements is to catch the event listeners that are triggered in the relevant iframe through the content script injected into each iframe. That is when click event occurs in the iframe and I need to get it to the extension. The diagram below shows how the web page related to my iframes exists and how content scripts are injected.

Iframe Hierarchy

The problem is that I want to get the events in the last frameReports iframe (see above image). Each iframe above has the correct content scripts injected except frameReports. frameReports has only one content script. The relevant content script is not injected so I cannot catch the event triggered in the iframe.

But when I temporarily remove the relevant iframe from the DOM through devtools, all the relevant content scripts injected properly. What is the reason for this? I am using manifest version 2. I’ll include the relevant files below.

Manifest.json

{
  "name": "Test",
    "version": "1.0.0",
      "manifest_version": 2,
        "description": "My Extension",
          "background": { },
  "permissions": ["tabs",
    "activeTab",
    "webRequest",
    "<all_urls>",
    "http://*/*",
    "https://*/*",
  ],
    "content_security_policy": "script-src 'self'; object-src 'self'",
      "content_scripts": [
        {
          "all_frames": true,
          "matches": ["http://*/*", "https://*/*", "file://*/*"],
          "js": ["contentScript.js"],
          "match_about_blank": true
        }
      ],
        "options_ui": {
    "page": "options/options.html"
  },
  "web_accessible_resources": ["icons/icon.png"]

}

contentScript.js

document.addEventHandler('click', function (event) {
    if (event.button == 0 && event.isTrusted) {
        var target = event.target;
    // Code goes here
    }
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!