View Full Version : Popup using like naming convention
I am building a website that contains several different image galleries--reptiles, birds, and mammals. Being graphic heavy I am displaying thumbnails of each picture. I would like the viewer to be able to click on the thumbnail to view the larger image in a popup window. I would rather not have to type the name of every photo. Can a Javascript be written that will open a window using the name of the thumbnail image by removing the thumbnail identifier? All my thumbnail have "_thumb" as their thumbnail status identifier.
Example:
thumbnail imaged named: frog_thumb.jpg
larger image named: frog.jpg
Can a script be written that will drop "_thumb" from an image name to open up the large image frog.jpg in a popup window?
Thanks
Togo
whammy
06-21-2002, 02:22 AM
woohoo... that sounds like a cool website... have the URL?
scroots
06-21-2002, 06:32 PM
http://www.javascriptkit.com has one a popup image viewer, take a look pretty neat.
scroots
Originally posted by Dave Clark
var img = document.images["imageName"];
var url = img.src;
alert(url);
url = url.split("_thumb").join("");
alert(url);
OK? :)
Thanks for the reply Dave. I hate to admit I am a graphics person not a programer. Could you spell you code out more for me? What goes where etc. Basically, huh,...how do I use it?
Togo
Originally posted by Dave Clark
OK. Let's see what your code, for your thumbnail, looks like.
Here is a code for a lizard picture. File of course changes for snakes, birds, plants etc.
<img src="/pictures/envior_pics/lizards/saurobes_thumb.jpg" width="175" height="97">
justame
06-22-2002, 03:35 AM
Originally posted by Dave Clark
with this IMG tag content:
<img src="/pictures/envior_pics/lizards/saurobes_thumb.jpg"
width="175" height="97" onClick="return popupImage(this);">
/me just a whispers® to dave...
ummm does netscrap just a support® the onClick in the 'img' tag??? /me doesnt seem to remember thinkin' it does??? /me thinks it hasss to be in the <a href="#" onClick="return popupImage(this);">your thumb here</a>
justame
06-22-2002, 02:15 PM
Originally posted by Dave Clark
OK? :)
dave...
just a yep® hehehe...
You could alternatively reverse the way you look at the needs
and use doc writes to do most
basefolder = "mysite/images/lizards/";
imges = new Array("yellow","red","blue","ghecko");
function popme(imgname) {
win = window.open(basefolder+imgname+'.jpg','win','width=440,height=340,resizable');
win.focus();
}
for (j=0;j<imges.length;j++) {
if (j=2) {document.write('<br>');}
document.write('<a href="javascript:popme(\''+basefolder+imges[j]+'_thumb.jpg"><img src="'+basefolder+imges[j]+'.jpg" border="0"></a>');
}
weird - it wrote in a smilie code :P
document.write('<a href="javascript: popme(''+basefolder+imges[j]+'_thumb.jpg"><img src="'+basefolder+imges[j]+'.jpg" border="0"></a>');
}
without the space in javascript: popme
justame
06-22-2002, 05:18 PM
poot...
"quote...Ökii - formerly pootergeist...endquote"
heyyy did/do you just a know® prince??? lol...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.