Detect before user closes/changes mobile browser tab
<p>Is it possible to detect before the user changes tab or closes the tab on a mobile browser. </p>

<p>I tried</p>

<pre><code>$(window).bind('beforeunload', function () {
           // AddToCart(123, 123, 123, 123);
            return "Message";
        });
</code></pre>

<p>but that did not work.</p>

<p>Any help would be great.</p>

<p>Thanks</p>
