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
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts

    iframe and its location.href

    I have made this litte code to show my problem, it makes an
    iframe with the name and id 'test', then make a var test to point
    to this iframe, my problem it the var says that location.href ain't an object. but if I write document.test.location.href it is, I would like a solution that lets me make a var called test and then reference location by
    test.location.href

    EXAMPLE CODE:
    <html>
    <head>

    </head>
    <body>
    <iframe id="test" name="test"></iframe>
    <script>
    var test=document.getElementById('test');
    alert(test.width);
    alert(document.test.location.href);
    alert(test.width);
    alert(test.location.href);

    </script>

    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    self.location
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that's because the iframe is a distinct window ... try accessing its location via:

    windowname.location.href

    notice that 'document' is not used.


  •  

    Posting Permissions

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