Breaking out of frames [message #30181] |
Thu, 09 February 2006 18:17 |
treebeard
Messages: 44 Registered: April 2004 Location: Huge Universe
Karma: 0
|
Member |
|
|
Recently another site "hijacked" our forum by framing it in a frameset with only one frame, src=our forum url. I added a bit of javascript to break out of the frame:
<Script Language="JavaScript">
<!--
setTimeout ("changePage()", 0);
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location= "index.php";
}
// -->
</script>
This should only check to see if the page is in a frame, and if so, break out to the self parent location. And it worked. However, several users started to complain about odd forum behavior, getting bounced back to the homepage, etc. So really two questions:
1) Is there a better way to prevent another site from framing the forum?
2) Why would this javascript cause problems if you're NOT browsing the forum in a frameset?
Thanks!
|
|
|
Re: Breaking out of frames [message #30204 is a reply to message #30181] |
Sat, 11 February 2006 20:26 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Ideally this should be inside an onLoad() event of the body tag. Inside it you should put something along the lines of:
if(parent.location.href!=location.href) top.location.href=location.href;
FUDforum Core Developer
|
|
|
|