Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.open

Status
Not open for further replies.

CliffLandin

Programmer
Nov 14, 2004
81
US
I am trying to create a gallery page that will show a series of photos and when you click on one it opens a new window and shows a larger image of the picture. It works fine, but the original page goes to a page called window.open

The page is
The code I am using is:

<a href="javascript:window.open('incs/large_Image.php?page=1','LargeWindow','top=0,left=0,width=640,height=480,resizable=yes,status=no,toolbar=no,menubar=no')">
<img src="imgs/db001.jpg" alt="Dirtbike 1" longdesc="The first dirt bike in the gallery" width="250" height="188" border="1" />
</a>
<a href="javascript:window.open('incs/large_Image.php?page=2','LargeWindow','top=0,left=0,width=640,height=480,resizable=yes,status=no,toolbar=no,menubar=no')">
<img src="imgs/db002.jpg" alt="Dirtbike 2" longdesc="The seconde dirt bike in the gallery" width="250" height="188" border="1" />
</a>
<br /><a href="javascript:window.open('incs/large_Image.php?page=3','LargeWindow','top=0,left=0,width=640,height=480,resizable=yes,status=no,toolbar=no,menubar=no')">
<img src="imgs/db003.jpg" alt="Dirtbike 3" longdesc="The third dirt bike in the gallery" width="250" height="188" border="1" />
</a>
<a href="javascript:window.open('incs/large_Image.php?page=4','LargeWindow','top=0,left=0,width=640,height=480,resizable=yes,status=no,toolbar=no,menubar=no')">
<img src="imgs/db004.jpg" alt="Dirtbike 4" longdesc="The fourth dirt bike in the gallery" width="250" height="188" border="1" />
</a>

Is there a way to open this new window without advancing the original page?

When in doubt, go flat out!

 
Your javacode needs to be under onclick, instead of href. Try this:

<a href="onclick="javascript:window.open('incs/large_Image.php?page=1','LargeWindow','top=0,left=0,width=640,height=480,resizable=yes,status=no,toolbar=no,menubar=no')"><br>
<img src="imgs/db001.jpg" alt="Dirtbike 1" longdesc="The first dirt bike in the gallery" width="250" height="188" border="1"><br></a></span>

However this might cause ur parent page to refresh. It depends on whether you want care or not. You can also try this, which to me is a better solution:

<a
onclick="javascript:window.open('incs/large_Image.php?page=1','LargeWindow','top=0,left=0,width=640,height=480,resizable=yes,status=no,toolbar=no,menubar=no')"><br>
<img src="imgs/db001.jpg" alt="Dirtbike 1" longdesc="The first dirt bike in the gallery" width="250" height="188" border="1"><br></a></span>

Just don't include the href, however you will loose the hand-shaped cursor, since it's not a link.

hope it helped. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top