Outline ·
[ Standard ] ·
Linear+
.NET script to detect browser close event?, .net / javascript
TSragk
|
Sep 29 2015, 05:57 PM, updated 9y ago
|
|
Hi, any1 knew how to detect a browser closing event? I have a session storing a collection of Data Table (for my services to do their work), i wanted to remove specify session when user close the tab/browser to avoid the session getting bigger and heavier, any good idea to achieve that? Have been playing with this whole day with body onunload / onbeforeunload event but nothing worked.
This post has been edited by ragk: Sep 29 2015, 05:57 PM
|
|
|
|
anangryorc
|
Sep 29 2015, 09:38 PM
|
|
|
|
|
|
TSragk
|
Sep 30 2015, 11:19 AM
|
|
QUOTE(anangryorc @ Sep 29 2015, 09:38 PM) doesn't work :-/
|
|
|
|
alien3d
|
Sep 30 2015, 11:25 AM
|
|
QUOTE(ragk @ Sep 29 2015, 05:57 PM) Hi, any1 knew how to detect a browser closing event? I have a session storing a collection of Data Table (for my services to do their work), i wanted to remove specify session when user close the tab/browser to avoid the session getting bigger and heavier, any good idea to achieve that? Have been playing with this whole day with body onunload / onbeforeunload event but nothing worked. you shouldn't worried about it unless you big as facebook.. a few kb okay la.
|
|
|
|
TSragk
|
Sep 30 2015, 02:52 PM
|
|
QUOTE(alien3d @ Sep 30 2015, 11:25 AM) you shouldn't worried about it unless you big as facebook.. a few kb okay la. yeah seems like only can give up on this, tested many methods doesn't work, and the function might fade away when browser updated
|
|
|
|
anangryorc
|
Sep 30 2015, 06:35 PM
|
|
CODE window.onbeforeunload = function (e) { return 'exiting...'; } Tested on chrome and ie11 its working. http://jsfiddle.net/0rxsz76o/This post has been edited by anangryorc: Sep 30 2015, 06:49 PM
|
|
|
|
TSragk
|
Sep 30 2015, 09:55 PM
|
|
QUOTE(anangryorc @ Sep 30 2015, 06:35 PM) CODE window.onbeforeunload = function (e) { return 'exiting...'; } Tested on chrome and ie11 its working. http://jsfiddle.net/0rxsz76o/hmmm, maybe something doesnt cope well in my script, i will check around again, thanks !
|
|
|
|
jurkflash
|
Oct 12 2015, 10:31 PM
|
Getting Started
|
QUOTE(ragk @ Sep 29 2015, 05:57 PM) Hi, any1 knew how to detect a browser closing event? I have a session storing a collection of Data Table (for my services to do their work), i wanted to remove specify session when user close the tab/browser to avoid the session getting bigger and heavier, any good idea to achieve that? Have been playing with this whole day with body onunload / onbeforeunload event but nothing worked. Practically no ways for server to know is client closed the browser.. But u can attempt below.. Javascript interval every few seconds post to a webservice, if no response coming back then u can kill off the session With all those code and time trial, i suggest avoid all these, store only needed stuff into the session and let it expire itself
|
|
|
|