Tutorial :How can I invoke a function when a user leaves my site?



Question:

I'm developing a website in VB.NET/ASP.NET 2.0.

I want to invoke an event (Server Side) once a user leaves my site by putting a different URL in the address bar, is it possible? If so, how?


Solution:1

Invoke the onbeforeunload event, like such :

window.onbeforeunload = function () {      //Your logic  };   


Solution:2

You can use the onbeforeunload JavaScript event to trigger when a user is about to navigate away from your site.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »