Michael Josephson <mike@josephson.org> wrote:

> As Steven says you aren't going to be able to determine the page the user
> is navigating to when they leave a page so you won't know if it's another
> part of the intranet or a different site.

Hmm... how about making all local links on the page call a function,
and then having the onunload complain if it hadn't been called? It's
not 100% reliable of course - no JavaScript ever is - but it would seem to
catch most circumstances.

Here's a standalone script you could link to on each page that would do
it automatically -

  var link_local= false;

  function link_unload() {
    if (!link_local)
      window.open('/logout.html', '_blank', '...options...');

  function link_click() {
    link_local= (this.href.host==window.location.host);

  function link_load() {
    var i;
    for (i= 0; i<document.links.length; i++)
      document.links[i].onclick= link_click;
    window.onunload= link_unload;

  window.onload= link_load;

(untested, but should work)