Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post

    DOM and the iframe DOM

    Now I have looked over a few articles on the web about accessing the DOM from an iframe in your current DOM, and I have found them to work...with one exception.

    Working with two local documents on my computer i can set one as the parent doc and the other as the iframe src.

    the parent doc can correctly tell me how many input elements there are in the iframe doc, and that's just perfect.

    However, if I have my parent element on my local computer, and the iframe source is... oh lets say.... http://www.google.com, I cannot get the parent doc to tell me how many tables are in the iframe doc.

    why is this?

    sample code: (assuming http://www.google.com is the src of your iframe ID=myFrame)
    Code:
    var oFrameDoc = document.getElementById("myFrame").contentDocument;
    var oTables = oFrameDoc.getElementsByTagName("table");
    alert(oTables.length);
    anthony

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    It's a security restriction placed by the browser itself. If this is for Internet Explorer, then try saving your file as .hta instead of .html. If this is for Gecko-based browsers, then save the file in a subdirectory of "chrome".

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post
    i'm not sure how you knew to suggest that but it still didnt work.

    in chrome under my firefox folder, i put the main doc and it still didnt reference any info from the DOM in the iframe.

    nt though
    anthony

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    You have to access it through a chrome: url.

  • #5
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post
    could you point me to an article that you found that information on? it sounds very interesting. Thanks for all the help thus far.
    anthony

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    I doubt an article would help you very much - there are not very many articles on the topic. I would instead direct you to developer related sites. Have a look at <http://developer.mozilla.org/>. There's also a nice collection of links on MozDev. <http://www.mozdev.org/docs/>
    Last edited by liorean; 02-03-2005 at 10:08 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    Regular Coder
    Join Date
    Dec 2002
    Location
    Minneapolis, MN
    Posts
    208
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by liorean
    I doubt an article would help you very much - there are not very many articles on the topic. I would instead direct you to developer related sites. Have a look at <http://developer.mozilla.org/>. There's also a nice collection of links on MozDev. <http://www.mozdev.org/docs/>
    i will take a look at those now. thanks.
    anthony


  •  

    Posting Permissions

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