Created
September 20, 2012 09:17
-
-
Save viveksoundrapandi/3754854 to your computer and use it in GitHub Desktop.
Trigger native window of browser
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
$(function(){ | |
var submitted = false; | |
//links having the below class will not trigger native widow | |
$(".cancel_submit").live('click',function (e){ | |
submitted=true; | |
}); | |
window.onkeydown = function(e){ | |
var key = e.keyCode ? e.keyCode : e.charCode ? e.charCode : false; | |
if (((e.ctrlKey || e.metaKey)&&key==82 )||key==116) | |
{ | |
submitted=true; | |
} | |
} | |
window.onbeforeunload = function() | |
{ | |
if(!submitted) | |
{ | |
// the string below will be displyed only in certain browsers, and others will display its own text | |
str = "Closing your browser window will cancel your loan application\nA new application on another site may result in additional credit checks that can impact your ability to get a loan."; | |
return str; | |
} | |
submitted=false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: You cant write an event listener for the buttons in this window for security reasons