Re: make window not pop to back

Giganews Newsgroups
Subject: Re: make window not pop to back
Posted by:  Dom Leonard (
Date: Sat, 19 Jul 2003

Eric Osman wrote:
> Hi,
> When I run the following html file on netscape, and the button is
> clicked, the new window pops BEHIND all my other windows.
> How can I easily fix this html file so the window comes up in front
> (like a standard alert window would) ?

Page below tested under Moz 1.3. Modifications include closing the
answer window if it is already open and getting the onload event of the
answer window to call focus. Simple call from onload didn't work, so
decoupled event processing through a timer. Tested in Moz only - would
need to test in more browsers before hitting the web :)



var popWin;
function showWin() {

    var hh="<HTML><HEAD><TITLE>Answer</TITLE>";
    hh+='<script type="text/javascript">';
    hh+='function raise(){self.focus();}';
    hh+='function decouple(){setTimeout("raise()",50);}';

    hh+="<BODY><form><textarea cols=30 rows=3>You may highlight or edit";
    hh += "</textarea></form></BODY></HTML>";
// --></script></head><button type=button
onmousedown='showWin();'>Press to create popup window</button></html>


In response to

make window not pop to back posted by Eric Osman on Fri, 18 Jul 2003