[thelist] Testing for the existence of a named spawned window

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Oct 4 10:01:04 CDT 2001


>Open it like this
>
>var newwin = window.open(etc)
>
>Then check
>
>if (newwin && !newwin.closed)
>{
>   window is open
>}
></snip>
>
>I think I know where this is going...

>The marketing people didn't want people "leaving" our site so they made the
>popUp mandatory.  Anyways, I'm wondering if anyone has already written the
>code to
>1) detect if the window is already open
>2) if it is, bring it to the front

var newwin;
function popitUp(url)
{
  if (newwin && !newwin.closed)
    newwin.location.href = url;
  else
    newwin = window.open(url,etc);
}

<A HREF="javascript:popitUp('http://www.greatsite.com')">Great Site!</A>

ppk

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp





More information about the thelist mailing list