Forum Moderators: open
var image_height = img.style.height;
if(image_height <= window_height / 100 * 70)
{
image_height = window_height / 100 * 80 + "px";
}
else
{
image_height = window_height / 100 * 80 + "px";
}
this works if i get elementbyid for the images but since id is a unique value it works only for the first image.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<base href="http://www.webmasterworld.com/theme/default/gfx/">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
<style type="text/css">
img{
border:1px solid #000;
}
</style>
<script type="text/javascript">
function resize_images(){
var gallery=document.getElementById('gallery');
var img=gallery.getElementsByTagName('img');
var window_height=document.getElementsByTagName('html')[0].clientHeight;
for(var c=0;c<img.length;c++) {
if(img[c].offsetHeight<=window_height*0.7) {
img[c].style.height=window_height*0.7+'px';
}
else {
img[c].style.height=window_height*0.7+'px';
}
}
}
window.onresize=function() {
resize_images();
}
window.addEventListener?
window.addEventListener('load',resize_images,false):
window.attachEvent('onload',resize_images);
</script>
</head>
<body>
<div id="gallery">
<img src="wilk.gif" alt="">
<img src="happy.gif" alt="">
<img src="sad.gif" alt="">
</div>
</body>
</html>