Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1352 How can I check to to see if I'm being framed by another site, without generating a JavaScript error?

irt.org | Knowledge Base | JavaScript | Frame | Q1352 [ previous next ]

Q1352 How can I check to to see if I'm being framed by another site, without generating a JavaScript error?

Try the following which works on JavaScript 1.1 enabled browsers:

<script language="JavaScript1.1"><!--
var topFrame = '';

function framed() {
    alert('framed');
    return true;
}

function isFramed() {
    topFrame = '';

    window.onerror=framed;

    topFrame = top.location.href

    if (topFrame.indexOf('http://www.mydomain.com') > -1) {
        // not framed
    }
}

isFramed();
//--></script>

Feedback on 'Q1352 How can I check to to see if I'm being framed by another site, without generating a JavaScript error?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.