Detect Browser Close
-
I want to clear a session by calling an assembly, How i deduct browser close button in javascript or vb.net. When the user click on the close button of browser i want to call a method in code behind. Thanks Mahesh
-
I want to clear a session by calling an assembly, How i deduct browser close button in javascript or vb.net. When the user click on the close button of browser i want to call a method in code behind. Thanks Mahesh
Detecting browser unload event. - Use onunload event of body tag to detect the closing of browser. Calling Server-side function from client-side script - Add a server-side hiddenfield to your page. - Write the code (eg: clearing a session) in the change event of this hiddenfield. - Grab this field and put some value to this hidden field from Javascript. As soon as the value is changed in this hiddenfield, the server-side event will be fired/invoked so that the code for clearing a session will be run. Hope it would help.. Let me know if you are not clear.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Detecting browser unload event. - Use onunload event of body tag to detect the closing of browser. Calling Server-side function from client-side script - Add a server-side hiddenfield to your page. - Write the code (eg: clearing a session) in the change event of this hiddenfield. - Grab this field and put some value to this hidden field from Javascript. As soon as the value is changed in this hiddenfield, the server-side event will be fired/invoked so that the code for clearing a session will be run. Hope it would help.. Let me know if you are not clear.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Michael, Thanks for reply. Well i write a function in javascript and call that function like that from inside the body tag onunload ="CloseBrow();" inside the CloseBrow how i detect when user click on Close button of browser, i must have to check that since page is unloaded every time when user move back and forth. I user some script inside that function "if (screenTop > 9999)" but this is working in some browser and not working in another browser. thanks and regards mahesh
-
Michael, Thanks for reply. Well i write a function in javascript and call that function like that from inside the body tag onunload ="CloseBrow();" inside the CloseBrow how i detect when user click on Close button of browser, i must have to check that since page is unloaded every time when user move back and forth. I user some script inside that function "if (screenTop > 9999)" but this is working in some browser and not working in another browser. thanks and regards mahesh
Yeah. You are right.. Have you tried this?
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Yeah. You are right.. Have you tried this?
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Yes I tried it. I tried this one also if (window.event.clientX < 0 || window.event.clientY < 0) This is working for IE in some machine and not for others. And I place a html button runat="server" whose display style is none after check this if (window.event.clientX < 0 || window.event.clientY < 0) i fired the button click from javascript and call a procedure in code behind, like that window.document.hidBut.click(); Pls let me know if there is another way to handle the close button of browser. regards mahesh