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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding the top frame URL?

    How would I find the most top frame on a page using javascript? For example, someone iframes my site within another iframe. I want to know the upper most frame's URL. How would I do that? Thanks.

    I tried using the code below but it only returns objects and not the URL. Does anyone know the correct way of doing it?

    Code:
    var TopFrame = (document.top == document.self);
    if (!TopFrame)
    {
    	TopFrame = true;
    }
    else
    {
    	TopFrame = top.frames[0];
    }
    thewird

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:
    Code:
    top.location.href
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kravvitz
    Try this:
    Code:
    top.location.href
    Thank you, That worked.

    thewird


  •  

    Posting Permissions

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