neil9999
10-17-2003, 10:39 AM
Hi,
I have the following code which should make a picture as big as possible, whilst keeping its ratios:
<script language='javascript'>
function resize(){
var fh=document.body.clientHeight;
var fw=document.body.clientWidth;
var ph=document.getElementById('piccy').height;
var pw=document.getElementById('piccy').width;
var fr=fh/fw;
var pr=ph/pw;
if(fr>pr){document.getElementById('piccy').width="100%"};
else{document.getElementById('piccy').height="100%"};
}
</script>
</head>
<body onload="resize()">
<p><img border="0" src="cat.bmp" id="piccy" width="244" height="200"></p>
If I open this up, the image doesn't display at all. If I change the two 100%'s to just 100 then the picture shows up, but distorted, so the image src is right. Why isn't this working?
Thanks,
Neil
I have the following code which should make a picture as big as possible, whilst keeping its ratios:
<script language='javascript'>
function resize(){
var fh=document.body.clientHeight;
var fw=document.body.clientWidth;
var ph=document.getElementById('piccy').height;
var pw=document.getElementById('piccy').width;
var fr=fh/fw;
var pr=ph/pw;
if(fr>pr){document.getElementById('piccy').width="100%"};
else{document.getElementById('piccy').height="100%"};
}
</script>
</head>
<body onload="resize()">
<p><img border="0" src="cat.bmp" id="piccy" width="244" height="200"></p>
If I open this up, the image doesn't display at all. If I change the two 100%'s to just 100 then the picture shows up, but distorted, so the image src is right. Why isn't this working?
Thanks,
Neil