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

151
Vistas
Check if the element inside an iFrame has any content

So I've tried to do a bunch of research and can't seem to find the correct answer for my question so I wanted to reach out and see if anyone knows much.

What I'm attempting to achieve:
Check the contents inside an iFrame and return a boolean whether there is content or not.

Here is what I've attempted:

function check_iframe_body_content(element) {
    let has_content = false;

    let iframe = element.contents().find('body');
    console.log(iframe);

    if (iframe.length > 0) {
        has_content = true;
    }

    return has_content;
}

The element is the iFrame return, which will be an array:
enter image description here

When the script tags are disabled, I get the following return:
enter image description here

When the script tags are enabled, I get the following return:
enter image description here

How can I properly determine if the <body> is empty and when it's not? I've tried to do .length on multiple different occasions and each time it comes back as has_content = true because it finds the body element, but it's actually empty.

All help will be appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You wont have access to the content inside iframe if it's loaded from another website as it's a major security breach. if that was possible a website could add an iframe to google.com and get access to user personal information like their email address, name and etc.

depending on why you want to check content of iframe, there might be other workarounds.

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