Re: make window not pop to back

Giganews Newsgroups
Subject: Re: make window not pop to back
Posted by:  Randell D. (…
Date: Fri, 18 Jul 2003

"Eric Osman" <ericosm…> wrote in message
> 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) ?
> Thanks.  /Eric
> Here's the html file (feel free to copy-paste it to try it) :
> <html><head><script><!--
> function showWin() {
>    var"","Pop","width=600,height=100,resizable=yes");
>    var hh="<HTML><HEAD><TITLE>Answer</TITLE></HEAD>";
>    hh+="<BODY><form><textarea cols=30 rows=3>You may highlight or edit";
>    hh += "</textarea></form></BODY></HTML>";
>    popWin.document.write(hh);
>    popWin.document.close();
> }
> // --></script></head><button type=button
> onmousedown='showWin();'>Press to create popup window</button></html>

Ah! Hope this helps you... I'm a newbie at javascript and I save some
responses to disk that I think I might want to use at some point... read the
post below (I think by a chap called Grant Wagner) and I hope it makes some
sense to you...

> > Grettings:
> > I have a website where clicking on an image will spawn a pop-up window
> > that will show a larger version of the image.  However, if the user
> > clicks on an image, it pops up in its own new browser window, and then
> > the user clicks on the old browser window, the new pop-up window will
> > revert back to the background and no window will pop-up if the user
> > clicks on a new image.  I know that I am bombarded with pop-ups
> > everytime I search the web.  Some of these pop-ups just run in the
> > background and I only see them after I have closed all of my other
> > browser windows. Is there a reverse of this? Can I embed some code in
> > the onload event to bring the pop-up browser window to the top if the
> > page reloads with a different image?
> Just add an
> nameOfPopUpWindow.focus();
> to your links.
> If you want to be nasty (which you do not want to be, of course), you can
> put a
> nameOfPopUpWindow.onblur="nameOfPopUpWindow.focus()";

If he puts that, nothing will happen onblur. Event handlers aren't strings,
they are references (pointers) to functions.

nameOfPopUpWindow.onblur = nameOfPopUpWindow.focus;

might do it, but I also have a problem with you saying "nameOfPopUpWindow",
because you don't call the focus() method on a window's name, you call it on
the reference (pointer) to the window.

> and your pop up will always remain in the foreground. However, the
> window cannot be accessed anymore now.

OP: To make it do what you seem to be asking, make the <body> tag of the
window look like:

<body onload="window.focus();">
<!-- your popup content goes here -->



In response to

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