View Full Version : Pop-Up Images


Vanessa023
11-20-2009, 03:07 PM
Hey Everyone,

As I can't get LightBox to work, I'd like to make a Gallery with Pop-Up images. I have thumbnails, as well as the large images.

I found this code on this site under JavaScript

<script language="javascript" type="text/javascript">
//<!--
function popup()
{ window.open ("YourURLgoesHere.html","popup","width=1000,height=700,location=0,menubar=0,resizab le=0,scrollbars=0,status=0,titlebar=1,toolbar=0") }
-->
</script>

Could I insert it WITHOUT the ".html" and instead it will pop-up the larger image? Gallery would include a succession of these codes.

<a href="javascript:popup()"><a href="bathrooms/baths-01.jpg"><img src="thumbs/baths-01.jpg" /></a>

Thanks,
Vanessa

iTom
11-21-2009, 09:46 PM
Here is something that you COULD use:

<script language="javascript" type="text/javascript">
//<!--
function popup(url)
{
window.open(url,"_" + Math.random(),"width=1000,height=700,location=0," + "menubar=0,resizable=0,scrollbars=0," + "status=0,titlebar=1,toolbar=0");
}
-->
</script>

<a href="javascript:popup('bathrooms/baths-01.jpg');"><img src="thumbs/baths-01.jpg" /></a>

You can insert any URL between the single quotes, so long as it doesn't have any single quotes in itself.

Note that this will open a new window each time you click on the link. It will not replace the current window. If you want to replace the window each time, change "_" + Math.random() to "popup".

Vanessa023
11-23-2009, 04:49 PM
Thanks so much for your help! The code looks great.

Just another question... Some of the images are landscape, which is appropriate for the 1050x700 parameters. But for the vertical photos, is there a way that I can individually overrule the '1050' so the window is properly sized to the photo?

Thanks a Bunch! :)

Vanessa023
11-23-2009, 05:40 PM
Also if you could help me with filling in the "location" tag? What exactly goes in there?

MANY thanks,
Vanessa

Vanessa023
11-23-2009, 06:42 PM
Third question... Sorry for being so needy! :blush:

We're getting an Error on Page message in IE. The script is working great in Safari/Firefox. Do you know whether or not this script is supported by IE, as the client will be viewing it with Explorer.

Thanks Again

iTom
11-23-2009, 10:08 PM
No problem I am happy to help a fellow web developer.

I don't have IE so I can't confirm it. I assume that popups are not disabled?

Try doing what I suggested, change "_" + Math.random() to "popup". IE might not like the unique code generator thing. Ugh.

What do you mean by 'location tag'? If you want to see the location bar, change location=0 to location=1 in the attributes list...