Welcome to WebmasterWorld Guest from 107.22.7.35

Forum Moderators: open

Message Too Old, No Replies

detecting if a page is loaded into an iframe

How can you?

     
10:09 am on Jan 15, 2004 (gmt 0)

10+ Year Member



Hi everyone,

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

3:51 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



I'm not claiming this is the correct solution but

<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.

7:08 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



I WOULD GIVE YOU A BIG HUG IF I COULD!

Do you need any webtraffic?

give me your url, i will give you 1000 clicks or 50,000 hits.

7:23 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



Oh that wont work, its breaking frames on traffic exchanges.

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.

8:11 am on Jan 16, 2004 (gmt 0)

10+ Year Member



I never claimed it was the right solution! Just hoped the script might go someway in helping you resolve.

So you are saying that certain domains + your domain can capture the page in a FRAMESET, and thats OK.

But if certain domains and/or others capture the page in an IFRAME than breakout.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month