Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!