www.webdeveloper.com
Results 1 to 2 of 2

Thread: access content of a remote page in iframe

  1. #1
    Join Date
    Jul 2006
    Posts
    6

    Exclamation access content of a remote page in iframe

    hi there
    i was wondering if it is possible to place a frame or an iframe on a page with a remote src and then access DOM objects of that page from main window to edit.

    say <iframe src="http://www.google.com"></iframe> and then read all the innerHTML inside iframe and write that to a div.

    for examle:
    <script>
    function change() { ht=window.frames[0].document.getElementById('innerdiv').innerHTML;
    document.getElementById('outerdiv').innerHTML = ht
    }
    </script>

    <button onclick = "change()">press</button>
    <frame src="http://www.google.com" frameborder = "1"></frame>
    <div id= "outerdiv"></div>

    thanks

  2. #2
    Join Date
    Dec 2003
    Posts
    70
    Quote Originally Posted by sina_izad
    hi there
    i was wondering if it is possible to place a frame or an iframe on a page with a remote src and then access DOM objects of that page from main window to edit.

    say <iframe src="http://www.google.com"></iframe> and then read all the innerHTML inside iframe and write that to a div.

    for examle:
    <script>
    function change() { ht=window.frames[0].document.getElementById('innerdiv').innerHTML;
    document.getElementById('outerdiv').innerHTML = ht
    }
    </script>

    <button onclick = "change()">press</button>
    <frame src="http://www.google.com" frameborder = "1"></frame>
    <div id= "outerdiv"></div>

    thanks
    You can't do that sorry.

    edit: I should elaborate...

    You cannot in any browser access html code (excluding javascript) of a page with a different domain and subdomain. If you could, no end user would be safe.

    The most you can do is this...

    Code:
    <script type="text/javascript" src="different domain"></script>
    Last edited by PhilDog; 04-25-2007 at 05:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles