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

    Smile How to find the top frame?

    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.

    thewird

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try
    top.frames[0]
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get [object Window] or [object] as the variable. I need to find the URL of the topframe. My current code is as follows...

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

  • #4
    New Coder
    Join Date
    Aug 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyone?

    thewird

  • #5
    New Coder
    Join Date
    Aug 2006
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I haven't been able to figure it out. Could anyone help me?

    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
    •