Created
August 3, 2010 13:17
-
-
Save enriquez/506351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (window.___dialogEncountered === undefined) { | |
window.___dialogEncountered = false; | |
} | |
if (window.___dialogReturnValue === undefined) { | |
window.___dialogReturnValue = false; | |
} | |
window.___dialogHandler = function(dialogType) { | |
window.parent.___dialogEncountered = dialogType; | |
return window.parent.___dialogReturnValue; | |
}; | |
window.alert = function() { return window.___dialogHandler('alert') }; | |
window.confirm = function() { return window.___dialogHandler('confirm') }; | |
window.prompt = function() { return window.___dialogHandler('prompt') }; | |
window.onbeforeunload = function() {}; // returning anything from this function causes popup | |
// handle frames | |
for (var i=0; i < window.frames.length; i++) { | |
try { | |
window.frames[i].alert = function() { return window.parent.___dialogHandler('alert') }; | |
window.frames[i].confirm = function() { return window.parent.___dialogHandler('confirm') }; | |
window.frames[i].prompt = function() { return window.parent.___dialogHandler('prompt') }; | |
window.frames[i].onbeforeunload = function() {}; | |
} catch(e) { | |
// frame src is most likely from a different domain | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment