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

237
Vistas
Opening and closing an iframe document within `onload`

Would there be any sort of issue or specification incompatibility caused by calling

 // assume iframe.contentWindow was checked beforehand and is defined
 iframe.contentWindow.document.open();
 iframe.contentWindow.document.close();

within the iframe onload function?

e.g.

iframe.onload = () => {
 // ...
 // assume iframe.contentWindow was checked beforehand and is defined 
 iframe.contentWindow.document.open();
 iframe.contentWindow.document.close();
}

The background to this is that when creating a friendly iframe, I want to get a reference to the iframe window and do certain operations with no / minimal writing to the iframe beforehand using document.write() and without having to use setTimeout (see https://bugs.chromium.org/p/chromium/issues/detail?id=978325 and https://bugs.chromium.org/p/chromium/issues/detail?id=961428 for why setTimeout would be needed)

The issue is that without calling open or when calling it prior to the onload function, the iframe location is set to about:blank (see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#opening-the-input-stream step 13). This can also be solved by adding a setTimeout after opening the document (outside of onload) at the cost of performance, which I would like to avoid.

The solution involving calling open and close within the onload function works on Chrome, Firefox and Safari, but JSDom considers the contentDocument to be null and the iframe itself to have no children when using this method (after manually simulating a call to onload, which is a separate issue, but might be related to the behavior)

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