...

View Full Version : JS frame breaker hlp..



Coastal Web
12-27-2005, 05:38 PM
Hello everyone I've got a quick question that l was hoping one of your Javascript Vets would be able to help me with...

My site uses the following javascript to "break" out of frames when a site links to mine using a framed page (which happens quite often):

<!--snip of code...
if (window != top) {
top.location.href = location.href;
}
//end of snip--->

However the situation has come up that l *want* to allow one specific domain to be able to link to my site, and keep the frames intact.

By using something like this:
<!--snip of code...
if ((window != top) && && (topURL.indexOf("www.someDomain.com") > 0)) {
top.location.href = location.href;
}
//end of snip--->

The question;
How would l set the variable of topURL to be that of the site that's linking to me with the frame?

Any help would be greatly appreciated.
Samantha gram

nikkiH
12-27-2005, 06:18 PM
top.location.href

konithomimo
12-27-2005, 08:21 PM
if ((window != top)&&(document.referrer!="http://www.allowedsite.com"))
{
top.location.href = location.href;
}

Coastal Web
12-28-2005, 12:43 AM
Thank you konithomimo;

<!--snip
str = document.referrer;
if ((window != top) && (str.indexOf("allowedDomain.com") < 0)){
top.location.href = location.href;
}
//end snip-->

does the trick

Samantha Gram

konithomimo
12-28-2005, 05:06 PM
You are very welcome.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum