Can javascript give me image dimensions?

R

Randell D.

Folks,
I want to create a popup for thumbnail images (jpg, png, gif) and wonder if
I can create a popup that opens a new window whereby the image fits the new
window 100%... I know I can have my Apache/PHP server do this, but my
preference leans towards clientside javascript...

Thus... can javascript calcuate the width/height of an image for me to do
the above?

thanx
 
R

Randell D.

Randell D. said:
Folks,
I want to create a popup for thumbnail images (jpg, png, gif) and wonder if
I can create a popup that opens a new window whereby the image fits the new
window 100%... I know I can have my Apache/PHP server do this, but my
preference leans towards clientside javascript...

Thus... can javascript calcuate the width/height of an image for me to do
the above?

thanx

Got it... from an old post...

<script Language='javascript1.2' type='text/javascript'>
<!--
function iLoad(isrc) {
var oImg = new Image();
oImg.src = isrc;
if (oImg.complete) {
window.alert(oImg.src + ' ' + oImg.width + ' x ' + oImg.height);
}
else {
window.setTimeout('iLoad(imgsrc)', 1000);
}
}
//-->
</script>
</HEAD>
<body onLoad='iLoad(imgsrc)'>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top