...

View Full Version : Resize image down....only if larger than 400 pixels?



Geolance
06-20-2004, 11:27 PM
Hello,

I am looking for some assistance if anyone would be willing to offer some.

I need to write a javascript to resize an image down to 400 pixels in width....but only if the image is greater than that value.

If the image is smaller than 400 pixels, I don't want it to resize. I'm sure this is simple and I'm hoping someone may be able to point me in the right direction.

Mr J
06-21-2004, 12:05 AM
Do you mean something like this


<HTML>
<HEAD>
<TITLE>Document Title</TITLE>

<script>
function test(){
if(document.mypic.width>400){
document.mypic.width=400
}
}
</script>

</HEAD>
<BODY onload="test()">


<img name="mypic" src="pic.jpg">
</BODY>
</HTML>

Geolance
06-22-2004, 07:52 AM
Yes.....that does exactly what I was hoping.

Thank you very much



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum