SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    unable to access contentDocument properties

    I have a very simple setup with an IFrame:
    Code HTML:
    <iframe height="550px" width="100%" border="0" id="iframeID" onload="javascript:proceed()">
    </iframe>
    The content of the frame is dynamically changed with JavaScript. Now after a page loads, i try to access it, but it won't work!
    Code JavaScript:
    var doc = frame.contentDocument ? frame.contentDocument : frame.contentWindow.document;
    alert(doc);
    alert(doc.body);
    The first alert works just like it should, but the second doesn't appear (and all further execution stops). There is no single property or element of the contentDocument i can reach. Can anyone help me to figure out the problem?

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var doc = frame.contentDocument ? frame.contentDocument : frame.contentWindow.document;
    alert(doc);
    alert(doc.body);
    Is the above the content of proceed?

    How do you expect to get an onload event if the iframe has no src? Are you applying it elsewhere?

    How do you get the frame reference?

    Are there any console errors?

    Can you see how you've made this a difficult question to answer?
    Tab-indentation is a crime against humanity.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •