Re: make window not pop to back

Giganews Newsgroups
Subject: Re: make window not pop to back
Posted by:  Randell D. (you.can.email.me.at.randel…@yahoo.com)
Date: Fri, 18 Jul 2003

"Eric Osman" <ericosm…@rcn.com> wrote in message
news:3F186949.20100…@rcn.com...
>
> 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 popWin=window.open("","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...
randelld

> > 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
original
> window cannot be accessed anymore now.

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

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

Replies

None

In response to

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