views:

220

answers:

0

On a page where I have a CKEDITOR text editor I have the following code to prevent the user from leaving the page and losing all their data:

window.onbeforeunload= function() {
    if (CKEDITOR.instances.stuff.getData().length > 0 && oktoquit == false) {
        return "You have unsaved changes. Click Cancel now, then 'Save' to save them. Click OK now to discard them.";
    }
};

CKEDITOR is loaded in an iframe. The issue is that in Internet Explorer 8, when a user clicks a btn in CKEDITOR, the dialog warning above is appearing. Interestingly, this is only hapenning in IE8 and not Safari, or FireFox.

Is there a way to update the code above to say just the main window or non iFrames?

Thanks