beytz
beytz

Reputation:

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

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?

Upvotes: 0

Views: 156

Answers (2)

Andreas Grech
Andreas Grech

Reputation: 107940

Invoke the onbeforeunload event, like such :

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

Upvotes: 1

George Stocker
George Stocker

Reputation: 57877

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

Upvotes: 0

Related Questions