views:

38

answers:

5

I just did a quick search for my question and couldn't find anything directly on point.

I'm still very new to HTML and was wondering if someone could tell me how I could add a picture to my website and set the code so that if I click on it, it enlarges the picture in a new window.

I'm going to be adding around 600+ pics to my website so I was also wondering if there's a way to write the code once and have it apply to all the pics I add.

Thanks in advance, - Danny B.

A: 

There are several ways to do this, but I'm assuming you'll have a simple site with lots of images on one page, and you'd like the images to zoom open "in a cool way".

Check out this: http://colorpowered.com/colorbox/

... click on View Demonstration and then see the various photo handling options.

This needs just some basic HTML and minimally configured Jquery. Very simple to use and produces a nice effect.

Tom
A: 

Google around using the keyword lightbox. Most of the solutions are ready-to-use Javascripts. Just include once, assign some IDs/classes, execute during onload and that's it. I personally have good experiences with Lightbox2 and jQuery Lightbox plugin.

BalusC
Its a pretty big step to jump from not knowing html at all to understanding jquery, but I guess this is probably the best route.
Joseph Silvashy
A: 

The simplest way would be to add a link to it, and set the target attribute to target="_blank". The link should point to the image itself. This would regularly open a new tab though, if you want a whole new window, you should try

href="javascript:window.open('myimage.png','_blank','toolbar=no,menubar=no,resizable=yes,scrollbars=yes')"
,which would open a new, standalone window. If you're looking for fade/resize effects and such, try one of the other answers posted.

henasraf
-1 for obstructive js. You *at least* want href="myimage.png" and the rest to be an onclick, if you must have it inline. Also, lightbox etc. do more than fade effects. They provide some standard UI built-in like close buttons and in-window opening.
D_N
just wondering why i got downvoted.. :/
henasraf
Sorry, meant to have my reason in there quicker.
D_N
You're right and I did wanna do that with onlcick, but I figured there wasn't *that* much of a difference at this point. Also, lightbox/jQuery/etc are great, but the guy's barely hit it off with HTML, I don't think thats what he should be messing with ;)
henasraf
Thanks everyone. When I get a chance I'm going to try these out, and get back on whether I've been successful or not. - Danny B.
+2  A: 

There's many many ways in which you could do this. The basic HTML for inserting an image with a link to a new window will be:

<a href="enlarged.html" target="_blank">
     <img src="photos/photo-name.jpg" />
</a>

But it is a fair bit more complicated if you want to be able to dynamically display a large number of photos. If you want to code this yourself, you'll want to look into using something like PHP to output the HTML code automatically for 600+ images. Then instead of pointing the link for each to a new page, you might want to consider having the images load in a cool way, such as a javascript lightbox/colorbox some of the other answers suggest.

One possible alternative solution might be to look for some pre-created photo album script. I don't have any experience of these so I'll let someone else make some suggestions on that.

Tom Castle
A: 

I decided to go w/ target="_blank" -- Lightbox2 seems like it'd be great, but I'm really not sure how to use it and where to put all the code. The instructions I've found for it still assume the user has some standard knowledge in the field, that of which I do not currently possess. So, I'll stick to the target/blank approach until I can get more familiar w/ coding and then I'll upgrade to Lightbox.

Once again, I want to say thanks to everyone. You guys always respond quickly and accurately.

With much appreciation, - Danny B