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 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2005
    Location
    Delhi
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    access all tags inside iframe

    Code:
    <HTML>
    <HEAD>
    <script type="text/javascript">
    function init(){
    var nodes = window.frames.anIframe.document.links;
    alert(nodes.item(2).text);
    }
    </script>
    </head>
    <BODY onLoad="init()">
    <A HREF="javascript: void 0"
       ONMOUSEOVER="window.frames.anIframe.location.href =
                      'http://JavaScript.FAQTs.com'"
    >
    JavaScript.FAQTs.com
    </a>
    <BR>
    <IFRAME NAME="anIframe" SRC="http://www.FAQTs.com"
            WIDTH="400"></iframe>
    </body>
    </html>
    This is my code.
    but it is giving an error of "access denied"
    please tell me how to access content inside an iframe

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    The code will work provided that the content of the iframe comes from the same domain as the main page. If it comes from a different domain then security mmakes it impossible for Javascript to reference the iframe and there is nothing you can do to change it.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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