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

170
Views
Getting window object with chrome extension

I am trying to get the window object in a chrome extension. Disclaimer: I'm a beginner.

So, if I go to the chrome console and type console.log(window), this will print me the window object. But if I do console.log(window) in my background.js, I will get the error Uncaught ReferenceError: window is not defined.

What am I doing wrong ??

Also, this is my manifest.json:

{
    "manifest_version": 3,
    "name": "test",
    "version": "1.0",
    "permissions": [
        "tabs"
    ],
    "host_permissions": [
        "*://*.mysite.com/*"
    ],
    "content_scripts":[
        {
            "matches": [
                "<all_urls>"
            ],
            "js": ["background.js"]
        }
    ]
}

Thanks for your help !

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After some further research I found the solution:

use document.defaultView

https://developer.mozilla.org/fr/docs/Web/API/Document/defaultView

about 4 years ago · Juan Pablo Isaza Report
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!