View Full Version : image pop ups???


leehobo
07-23-2003, 10:44 AM
Is there any way of having an image as a link and when u click the image it opens it in a new window and the window will be the same size as the image.

thanks

bellportal
07-23-2003, 10:55 AM
Simple answer: Yes.

Harder answer: Yes. To do this you need JavaScript...

In the <head> of your page type:


<Script Language="JavaScript">
function Opener()
{
window.open("image.jpg",null,"height=PictureHeight, width=PictureWidth")
}


Then type the code for the image that will be clicked on:

<img src="image.jpg" javascript:onClick="Opener()">

Change everything not in blue to your spec. and it should work like a dream (If only web design was that easy!)

Because of the justification the forum uses, you may have to remove any spaces in words like 'javascript'.

HTH,

leehobo
07-23-2003, 01:30 PM
i tryed it but it didnt work :(

the_dark_one02
07-23-2003, 02:06 PM
I had EXACTLY the same question ages ago, and this is were i found the answer!:

http://www.codelifter.com/main/javascript/autosizeimagepopup.html

leehobo
07-23-2003, 07:47 PM
wow thanks that a great link

leehobo
07-24-2003, 01:36 PM
i tryed it but when i clicked on the link the pop up came up and it was an x as if the image wasnt uploaded or something. I was think this might work but it doesnt have the browser size thing

<A HREF="http://www.pageresource.com/linkus.htm" target="_blank">
<IMG SRC="http://www.pageresource.com/images/scare.jpg">
</A>

any one know how i could change the size of the new browser window?

Lissa
07-24-2003, 01:49 PM
This is how I did it, the instructions are on my site.

http://www.lissaexplains.com/basics.shtml#start

At the URL above, look for the link called "Magitek"

Click on it, an image fills the whole window, I think that's what you want.

I did it by following these instructions to the letter:


http://www.lissaexplains.com/javascript4.shtml#window


You can resize the window to the exact width and height of the image. You need to put the image on an html page.

That's the easiest way I've found.

leehobo
07-24-2003, 05:39 PM
yea... that workis fine and everything but u can only have one image popup i have multipule images that need to pop up, so is there any way around it to have more than one image popping up?

leehobo
07-24-2003, 07:36 PM
any help would be greatly appreciated, i've tried messing around with the script but it is still only allowing 1 image to pop up

bellportal
07-24-2003, 07:45 PM
Sorry about my code. I'm not a great JavaScript wonder!

*sniffs and then cries bitterly into a hanky closeby*

Lissa
07-24-2003, 07:51 PM
Originally posted by leehobo
any help would be greatly appreciated, i've tried messing around with the script but it is still only allowing 1 image to pop up


Just name each window differently here in the script tag:


function popup()
{ window.open ("YourURLgoesHere.html","popup","width=400,height=400,location=0,menubar=0,resizabl e=0,scrollbars=0,status=0,titlebar=1,toolbar=0") }

And here where you actually call the window:

<a href="javascript:popup()">Click here for popup window"</a>

Instead of "popup" you could call them window1, window2 etc.