when tabbed browsing, how to tigger an event in javascript when one of the pages is closed.
<p>I am trying to monitor when the broswer is closed.  Yes, I have tried, and got a result with the javascript function <code>onbeforeunload()</code>.  It works well when I click the red "X" button on the top-right to close the broswer, or press Alt+F4.</p>

<p>The problem is I want to trigger the event in these cases:</p>

<ul>
<li>tabbed browsing closes one of the pages </li>
<li>your PC powers off</li>
<li>redirect to other website (not when refreshing the page by pressing F5, I just mean from one website to another)</li>
</ul>

<p>e.g "www.google.com" redirect to "www.microsoft.com", it will do, but "www.google.com/webhp?client=AAAAA&amp;newwindow=AA&amp;channel=AAA" redirect to "www.google.com/webhp?client=XXXXX&amp;newwindow=xx&amp;channel=xx" it won't).</p>
