Accessing Div in IFrame

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • theone3000
    New Member
    • Jan 2007
    • 4

    Accessing Div in IFrame

    Hi All,
    I am trying to access a div in an iframe(the div is the first object within the body tag, no table, text, etc), i walked the dom tree in the "Dom Inspector" in mozilla, but cannot make sence of what javascript method to use and how to access the innerhtml of a div!.
    how do i do this?, is there any tools that are freely avilable on the net to do this?
    thanks all!
    :D
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to thescripts.

    To access the innerHTML of a div, just write the following:
    Code:
    var str = document.getElementById('divid').innerHTML;
    where 'divid' is the id of your div.

    See this page and this one for more info. on iframes and the DOM.

    If you need more help, post again.

    Comment

    • theone3000
      New Member
      • Jan 2007
      • 4

      #3
      Not realy help,
      if i want to grab the innerHTML of a div on the main page, that would work, but in an iframe, it doesn't work,gotta walk the dom tree, i used document.getEle mentById("MyFra me").contentDoc ument but the problem it returns the item as a html object, what and how do i access it now? i have tried all the normal combinations with no success!, and that is for netscape, what about IE?

      Comment

      • theone3000
        New Member
        • Jan 2007
        • 4

        #4
        Hi All, got some more data,
        I noticed that when i refresh/load the page, it can access the iframe's contents, and even change the bg color, but when it loads a page, it is denied access, can a page its self block access?, how could it do this?, and, is there a freeware tool that can be implemented so i can watch/track/record each action by the page being loaded into the iframe so as i can find a work around?
        thanks all

        Comment

        • theone3000
          New Member
          • Jan 2007
          • 4

          #5
          when i posted the last item, i had a fair idea that it would not get answered, and would baffle most/all, but i found the answer, for all!, thanks to the kind people at Uni Massachusetts Amherst, and here it is! http://www.umass.edu/microbio/chime/pe_beta/pe/protexpl/notes/browbarr.htm

          my problem is with firefox, and i believe that there are probably other security issues too.

          Now to do a work-around!

          Comment

          • baden2500
            New Member
            • Oct 2006
            • 2

            #6
            Originally posted by theone3000
            when i posted the last item, i had a fair idea that it would not get answered, and would baffle most/all, but i found the answer, for all!, thanks to the kind people at Uni Massachusetts Amherst, and here it is! http://www.umass.edu/microbio/chime/pe_beta/pe/protexpl/notes/browbarr.htm

            my problem is with firefox, and i believe that there are probably other security issues too.

            Now to do a work-around!
            If there are different servers (main page and iframe) you can't access iframe-DOM from main page and viceversa.

            Comment

            Working...