Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

69
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda