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

68
Views
Inject library wrapped with IIFE to child window opened with React app

I have library which wrapped with an IIFE and placed to .js file,and it looks and works generally in this way:

(function (libraryObject) {

    libraryObject.doSomething = function (){
    document.getElementById() ....
}



})((window.library = window.library || {}));

When I import it to my React app I just do: import './library'

So it injects to window in which my React app initialized.

And document object also belongs to this window and when I call for ex:

window.library.doSomething() It will work with context of this document, so document.getElementById() .... inside library will work with the same document.

But I need open an child popup with const myChildPopup = window.open() and inject this library in context of my child popup and next library can do something in document of my child popup, something like this:

myChildPopup.libraryObject.doSomething().

So that the document object in this case inside library will reffer myChildPopup.document. For ex: document.getElementById() .... // document === myChildPopup.document

Any ideas how to do this?

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!