Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

75
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda