Just think on it a bit: suppose your user already "shifted" to some Web site. What does it mean? It simply means that the user sent some HTTP request to other site, received HTTP response, rendered the page, elaborated some scripts, etc. Too late — at this moment, current page has nothing to do with your site.
Of course you can prevent navigation out of your site. Theoretically speaking, a Web browser could trigger some event
before navigating out of your site. Unfortunately, the event
onbeforeunload
is
proprietary to Microsoft, see
http://msdn.microsoft.com/en-us/library/ms536907%28v=vs.85%29.aspx[
^], so you cannot reliably use it as it may not work with different browsers. I did not even try, please see
http://discuss.joelonsoftware.com/default.asp?design.4.357494.19[
^].
Moreover, even the
window.onunload
event processing is different in different browsers. I just tested it with IE under Microsoft JavaScript debugger — it can accept one parameter with a lot of even information. Unfortunately, this is not part of the standard and not documented.
—SA