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

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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