Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6722805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:29:30+00:00 2026-05-26T09:29:30+00:00

I have a element as below inside the document, I could get the iframe

  • 0

I have a element as below inside the document, I could get the iframe element by document.getElementById('iframe_id'), but how to get the element inside this iframe? I tried iframeElement.contentWindow, and the returned DOMWindow has no properties. Also tried iframeElement.docuemnt and iframeElement.contentDocument, both of them are undefined. How can I get it? I am using the latest Chrome in my experiment.

Here is the iframe element

<iframe id='iframe_id'>
<html>
<body>many content here</body>
</html>
</iframe>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:29:30+00:00Added an answer on May 26, 2026 at 9:29 am

    You can ONLY interrogate content in an iframe if the content has the same protocol, domain and port number as the script that interrogates it. It is called SAME ORIGIN

    If that is the case, then this code will show the content. If not – you cannot access the iframe from a normal script in a normal html page

    Demo – tested in IE8, Chrome 13 and Fx6

    function showIframeContent(id) {
      var iframe = document.getElementById(id);
        try {
          var doc = (iframe.contentDocument)? iframe.contentDocument: iframe.contentWindow.document;
          alert(doc.body.innerHTML);
        }
        catch(e) {
           alert(e.message);
        }
      return false;
    }
    
    
    <iframe id='iframe_id1' src="javascript:parent.somehtml()"> </iframe>
    <br/>
    <a href="#" onclick="return showIframeContent('iframe_id1')">Show</a>
    <hr/>
    
    <iframe id='iframe_id2' src="http://plungjan.name/"> </iframe>
    <br/>
    <a href="#" onclick="return showIframeContent('iframe_id2')">Show</a>
    <hr/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I remove certain element inside html()? For instance, I have this html
I have an element in my document that has a background color and image
I have an element which may contain very big amounts of data, but I
I have an element like this: <div id=foo_<?php echo $id;?> class=hidden></div> I'm trying if
I need to have a single <li> element which has two buttons inside of
I have an input element inside a div element: ... <div id=calculator-container> <input type=text
I'm trying to get a SVG 'text' element fitting inside of a svg 'rect'
Ok, I have an in template function that get's submitted via method=POST. But I
I have an element( 2 anchors next to each other) inside the div(spans about
I have an XML form with an element 0, which is well-formed but not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.