I want to determine when user is leaving the site using javascript. By site I means domain here.

The body unload occur before leaving any page. So it won't do the job. But is there any way to capture where the user is headed? So when the address is on another domain something is alerted by this event.

Another way, attach an onclick or onsubmit to any inner form and inner link. On this events we set a variable so on unload understand that we are going to an inner page. Maybe you suggest a script that do that automatically but without any javascript framework.

Dears, I don't want to use this as a "please, stay on my site". I want to ask those user that go to order page but anyhow can't submit and finalize the order, and leaving our site to contact us on the phone. So please don't judge it.