How to detect browser window or tab close event or a redirection on client side.
My requirement is, in my project while submitting a form I am uploading files asynchronously and i dont want user to close the tab or move to the different page until the uplaoding is done. I simply want to show a popup to user to wait until all files are
uploaded.
jaydeep.chou...
Member
13 Points
41 Posts
Detect browser close event or redirection in javascript
Aug 09, 2012 07:28 AM|LINK
Hi,
How to detect browser window or tab close event or a redirection on client side.
My requirement is, in my project while submitting a form I am uploading files asynchronously and i dont want user to close the tab or move to the different page until the uplaoding is done. I simply want to show a popup to user to wait until all files are uploaded.
How to achive this using javascript or jQuery??
JQuery javascript
avinash_bhud...
Contributor
2881 Points
517 Posts
Re: Detect browser close event or redirection in javascript
Aug 09, 2012 07:37 AM|LINK
You could use window.onbeforeunload function in javascript
window.onbeforeunload = function(e) { // check condition return 'Dialog text here.'; };following are some links
https://developer.mozilla.org/en-US/docs/DOM/window.onbeforeunload
http://stackoverflow.com/questions/1889404/jquery-ui-dialog-onbeforeunload
Using JQuery
http://www.mkyong.com/jquery/how-to-stop-a-page-from-exit-or-unload-with-jquery/
http://dotnetkicks.com/aspnet/Use_jQuery_to_standardize_window_onbeforeunload_across_browsers
http://www.webhostingtalk.com/showthread.php?t=927093
JQuery javascript
asteranup
All-Star
30184 Points
4906 Posts
Re: Detect browser close event or redirection in javascript
Aug 09, 2012 08:49 AM|LINK
Hi,
You can check these-
http://delicious.com/anupdg/onbeforeunload
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog