Page 1 of 1

? HTML - Bring window to front ?

Posted: Tue 13 Apr, 2004 17.11
by Martin
Got a small problem....

I've got a set of images as thumbnails, when I click on one it opens up a new window (only a small one) with the bigger size of that pic showing, should I click on another thumbnail before closing the window it displays the new image in the same window only now its not visible (unless you click on it on the taskbar). I want it so that when I click on a new window it brings that back to the front so the view can see it easily.

Is it possible?

I've tried searching for a piece of code for it but its just returning pop up scripts and the like :?

Thanks
Martin

Re: ? HTML - Bring window to front ?

Posted: Tue 13 Apr, 2004 17.47
by Neil Jones
Martin wrote:I've got a set of images as thumbnails, when I click on one it opens up a new window (only a small one) with the bigger size of that pic showing, should I click on another thumbnail before closing the window it displays the new image in the same window only now its not visible (unless you click on it on the taskbar). I want it so that when I click on a new window it brings that back to the front so the view can see it easily.
This is browser and OS controlled, by default it's a "first come first served" situation, although in my experience IE6 seems to overrule this at times especially so far as forms are concerned and Windows seems to forget about it full stop. One can alter this behaviour with TweakUI and prevent focus stealing.

Therefore, if you have a small window behind the main window, it should not come forward. One can see this action with Outlook Express, if you click a link in a message to open a new window and then click another link it opens in the same window but doesn't (usually) steal focus, yes?
I've tried searching for a piece of code for it but its just returning pop up scripts and the like :?
That'll be because it is exactly what you want. It is simply a popup script, which is not a "stick this in front of the browser if it's not already open" script. Generally a new poppy-up window will appear in front of the main window if it isn't already open unless it's been defined as a pop behind window. It's then generally not the script's problem if the window it's trying to open is behind the current window as it's only concerned with opening it. You may be able to get it to grab the focus but not really recommended IMO.

Posted: Tue 13 Apr, 2004 18.01
by Chris
Does anyone know where I can get a popup script like the ones used on this page that resizes according to the size of the image being displayed?

Posted: Tue 13 Apr, 2004 18.26
by Martin
Chris wrote:Does anyone know where I can get a popup script like the ones used on this page that resizes according to the size of the image being displayed?
Don't know if this will be of any use to you...http://javascript.internet.com/page-det ... iewer.html

Found it while trying to solve my problem.

Re: ? HTML - Bring window to front ?

Posted: Tue 13 Apr, 2004 18.39
by Martin
Neil Jones wrote:
Martin wrote:I've got a set of images as thumbnails, when I click on one it opens up a new window (only a small one) with the bigger size of that pic showing, should I click on another thumbnail before closing the window it displays the new image in the same window only now its not visible (unless you click on it on the taskbar). I want it so that when I click on a new window it brings that back to the front so the view can see it easily.
This is browser and OS controlled, by default it's a "first come first served" situation, although in my experience IE6 seems to overrule this at times especially so far as forms are concerned and Windows seems to forget about it full stop. One can alter this behaviour with TweakUI and prevent focus stealing.

Therefore, if you have a small window behind the main window, it should not come forward. One can see this action with Outlook Express, if you click a link in a message to open a new window and then click another link it opens in the same window but doesn't (usually) steal focus, yes?
I've tried searching for a piece of code for it but its just returning pop up scripts and the like :?
That'll be because it is exactly what you want. It is simply a popup script, which is not a "stick this in front of the browser if it's not already open" script. Generally a new poppy-up window will appear in front of the main window if it isn't already open unless it's been defined as a pop behind window. It's then generally not the script's problem if the window it's trying to open is behind the current window as it's only concerned with opening it. You may be able to get it to grab the focus but not really recommended IMO.
Thanks for that.

I've found this script http://javascript.internet.com/page-det ... indow.html
Seems exactly what I need, although it will keep the window open permenantly but that wouldnt matter if it meant the user closed it each time, only problem is how do I get it out of a button and into the standard way of linking through an image?

From:
<INPUT TYPE="BUTTON" VALUE="Pop-Up" onClick="topWindow()">

Into (current method):
<a href="javascriptStart('http://www.)";>

Re: ? HTML - Bring window to front ?

Posted: Tue 13 Apr, 2004 20.12
by Neil Jones
Martin wrote:I've found this script http://javascript.internet.com/page-det ... indow.html
Seems exactly what I need, although it will keep the window open permenantly but that wouldnt matter if it meant the user closed it each time, only problem is how do I get it out of a button and into the standard way of linking through an image?

From:
<INPUT TYPE="BUTTON" VALUE="Pop-Up" onClick="topWindow()">

Into (current method):
<a href="javascriptStart('http://www.)";>
Use this for a text link:

Code: Select all

 <a href="javascripttopWindow()">Open on top</a> 
And for an image:

Code: Select all

<a href="javascripttopWindow()"<img src="image.gif" border="0" /></a>
Javascript function names are case sensitive.

Posted: Tue 13 Apr, 2004 21.20
by cdd
add onload="opener.blur; self.focus()" to your <body... > tag.

Alternatively on the window where you click to launch up the window define the window previously (call it newwin) and then in the open window function apply a function newwindow(x), in the function {newwin.close(); window.open(""+x+"",newwin,[attributes]);}

Posted: Wed 14 Apr, 2004 19.30
by Martin
Thanks to both of you, its now doing what I wanted.

Martin