...

View Full Version : Finding the top frame URL?



thewird
09-02-2006, 02:52 AM
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?


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

thewird

Kravvitz
09-02-2006, 03:39 AM
Try this:

top.location.href

thewird
09-02-2006, 04:20 AM
Try this:

top.location.href
Thank you, That worked.

thewird



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum