homepage Welcome to WebmasterWorld Guest from 54.205.254.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
detecting if a page is loaded into an iframe
How can you?
autohits




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

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

 

HocusPocus




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

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.

autohits




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

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.

autohits




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

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.

HocusPocus




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved