Hi,
yes there is a good one:
<script language=javascript>
function iwh(i)
{
x=new Image;
x.src=i;
iw=x.width;
ih=x.height;
alert("Image width is: "+iw+" pixels, and image height is: "+ih+" pixels.");
}
</script>
<img src=1.jpg onClick="iwh('1.jpg')">
<img src=2.jpg onClick="iwh('2.jpg')">
1-The script must be between the <head> tags,
2-The onClick event of the image must contain the image's url as an argument of the function.
This link is an exemple:
http://www.rissala.shajara.net/p2p/iwh.htm
This are tow different methods to explain some parts of the script:
FIRST
<script language=javascript>
function iwh()
{
iw=document.images.img1.width;
ih=document.images.img2.height;
alert("Image width is: "+iw+" pixels, and image height is: "+ih+" pixels.");
}
</script>
<img src=1.jpg ID=img1 onClick="iwh()">
<img src=2.jpg ID=img2 onClick="iwh()">
img1 is the ID of the image that you should write to identify the image,
SECOND
It can be replaced by the number of the image in the page (the first is 0):
iw=document.images[0].width;
ih=document.images[0].height;
so in such case you can put just one time to get the width and height, so you pass the image number to the function as an argument of onClick="iwh(image_number)" :
yes there is a simple one:
<script language=javascript>
function iwh(x)
{
iw=document.images[x].width;
ih=document.images[x].height;
alert("Image number is : "+x+". Image width is: "+iw+" pixels, and image height is: "+ih+" pixels.");
}
</script>
<img src=1.jpg onClick="iwh(0)">
<img src=2.jpg onClick="iwh(1)">
THE WHOLE script with open new window:
<html>
<head>
<script language=javascript>
function iwh(i)
{
var iw;
var ih;
x=new Image;
x.src=i;
iw=x.width;
ih=x.height;
alert("Image width is: "+iw+" pixels, and image height is: "+ih+" pixels.");
// i saw it on :
//http://forums.devshed.com/archive/t-95918
Imagew=window.open('i.htm','Imagew',' width='+iw+',height='+ih+',toolbar=0
,resizable=0 ');
Imagew.document.write("<head><title>Image</title></head><body topmargin=0
leftmargin=0><img src="+i+" onClick='window.close();'>");
}
</script>
</head>
<body topmargin=100 ><center>
<a href="#" onClick="iwh('1.jpg')"><img src=1.jpg onClick="iwh('1.jpg')" height=150></a>
<a href="#" onClick="iwh('2.jpg')"><img src=2.jpg onClick="iwh('2.jpg')" height=150></a>
<center></body></html>
I hope that it helps,