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!

How to popup images in new window?

Status
Not open for further replies.

j420exe

MIS
Feb 17, 2002
28
US
I have a list of image links on a page and when I click on one of the links I would like to have a popup window display the image. How can I do this?
 
this should work:
Code:
<script language=&quot;javascript&quot;><!--
function imager(n)
{
var image = document.images[n].src; //sets img src to var
document.form1.input1.value = image; //sets hidden input to
// image
}
function preview()
{
var newWindow = window.open(&quot;bigimage.html&quot;);
}
//--></script>
then your images & links:
Code:
<a href=&quot;javascript:preview()&quot;>
<img src=&quot;blah.bmp&quot; onMouseOver=&quot;imager(0)&quot;></a>
<a href=&quot;javascript:preview()&quot;>
<img src=&quot;blah2.bmp&quot; onMouseOver=&quot;imager(1)&quot;></a>
then in your new window:
Code:
<html>
<body>
<img src=&quot;&quot;>
<script language=&quot;javascript&quot;><!--
document.images[0].src = opener.document.form1.input1.value;
//--></script>
</body>
</html>
your hidden input should look like this:
Code:
<input type=&quot;hidden&quot; name=&quot;input1&quot;>
hope this helps

The pen is mightier than the sword.
 
heh, i was still typing when roblasch answered this, and had yet to see it. -- you could combine our methods to get a more complete thing like so:
Code:
<script language=&quot;javascript&quot;><!--
function imager(n)
{
var image = document.images[n].src; //sets img src to var
var newWindow = window.open(image);
}
once again..the images:
Code:
<a href=&quot;javascript:preview()&quot;>
<img src=&quot;blah.bmp&quot; onMouseOver=&quot;imager(0)&quot;></a>
<a href=&quot;javascript:preview()&quot;>
<img src=&quot;blah2.bmp&quot; onMouseOver=&quot;imager(1)&quot;></a>

that should work!
The pen is mightier than the sword.
 
Since you say you already have a list of links, the easiest way is to just add target=&quot;_blank&quot; to each link. It's a low-tech solution, but it works. And it should work in ALL browsers. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top