Forum Moderators: open
I know how detect if a page is loaded into frames.
But I need to be able to detect if it loaded into an iframe, and if it is, I want it to break frames.
I DO NOT want it to break out of normal frames, only if it is loaded into an iframe.
Thank You For Your Help!
And I will give 50,000 Hits to anyones site that delivers a solution. @ AutoHitsNow.com
<SCRIPT language="JavaScript" TYPE="text/JavaScript">
function handleError() {
window.parent.location=location
}
window.onerror = handleError;
if (window.parent.frames.length>0) {
if (window.parent.document.body.innerHTML) {
//do nothing
}
}
</SCRIPT>
Basically the script breaks out of an IFRAME if the the parent document is not under the same domain as the captured document.
That is, the script is trying to read the innerHTML of parent doc. It can't do this if it's under a different domain- an Access Denied Error is fired. The onError event deals with this and breaks the child doc out of the iframe.
I'll sticky you my details.
I need it to just break out of and iframe, if in an iframe, no matter what the url is.
See, its breaking frames when loaded from another url in a normal frame. That wont work it will disrupt other traffic exchanges.
I just need it to detect if the page is loaded into an iframe, then break no matter what the url is.