IzzieLeeLucas
11-20-2003, 11:24 AM
Hi,
I've written some basic javascript which, when an image thumbnail is clicked on, will open up a named child window of a specified size. Then, using getElementById, I changed the SRC in the IMG tag on the new window to specify an image to display. (I hope that makes sence)
As I have lots of image thumbnails on one page and different sized images I decided that rather than have a different Javascript Function for each image, I would specify the size and the image to diplay in the onClick of the thumbnail.
From the way I try to explain things, You may have no idea what I'm talkin about so heres the script (cut down slightly to save space)...
HTML File 1 (pictures.html) - Displays the thumbnails
<html>
<head>
<script language="JavaScript">
function open_window(mwidth,mheight){
picture = eval('window.open("image.html","","width='+mwidth+',height='+mheight+'")');
}
function load_image(location){
var pic = picture.document.getElementById("image");
pic.src = location;
}
</script>
</head>
<body>
<img onClick="open_window(340,558);load_image('pic1.jpg');" border="0" src="thumbpic1.jpg" width="60" height="100">
<br>
<img onClick="open_window(325,458);load_image('pic2.jpg');" border="0" src="thumbpic2.jpg" width="60" height="100">
</body>
</html>
HTML file 2 (image.html) - Contains the image
<html>
<head>
</head>
<body>
<img src="" id="image">
</body>
</html>
Now my problem is this... what I've written works perfecly fine when I run it from my computer harddrive, but when I upload it to my server, the child window will come up, but the image won't display. I just get a small box outline with the red X in it.
How come it will work on my computer but not on the server? I have other javascript running on it fine.
Thanks for any help,
Izzie
I've written some basic javascript which, when an image thumbnail is clicked on, will open up a named child window of a specified size. Then, using getElementById, I changed the SRC in the IMG tag on the new window to specify an image to display. (I hope that makes sence)
As I have lots of image thumbnails on one page and different sized images I decided that rather than have a different Javascript Function for each image, I would specify the size and the image to diplay in the onClick of the thumbnail.
From the way I try to explain things, You may have no idea what I'm talkin about so heres the script (cut down slightly to save space)...
HTML File 1 (pictures.html) - Displays the thumbnails
<html>
<head>
<script language="JavaScript">
function open_window(mwidth,mheight){
picture = eval('window.open("image.html","","width='+mwidth+',height='+mheight+'")');
}
function load_image(location){
var pic = picture.document.getElementById("image");
pic.src = location;
}
</script>
</head>
<body>
<img onClick="open_window(340,558);load_image('pic1.jpg');" border="0" src="thumbpic1.jpg" width="60" height="100">
<br>
<img onClick="open_window(325,458);load_image('pic2.jpg');" border="0" src="thumbpic2.jpg" width="60" height="100">
</body>
</html>
HTML file 2 (image.html) - Contains the image
<html>
<head>
</head>
<body>
<img src="" id="image">
</body>
</html>
Now my problem is this... what I've written works perfecly fine when I run it from my computer harddrive, but when I upload it to my server, the child window will come up, but the image won't display. I just get a small box outline with the red X in it.
How come it will work on my computer but not on the server? I have other javascript running on it fine.
Thanks for any help,
Izzie