Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Frame | Q1352 [ previous next ]

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?'

©2018 Martin Webb