在网上找到的,据说是百度源码的用js控制图片的代码,希望有人可以将使用鼠标滑轮控制图片的代码贴上。
<html>
<head>
<script language=Javascript>
var proMaxHeight = 300;
var proMaxWidth = 200;
function proDownImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
var rate = (proMaxWidth/image.width < proMaxHeight/image.height) ? proMaxWidth/image.width:proMaxHeight/image.height;
if(rate <= 1){
ImgD.width = image.width*rate;
ImgD.height =image.height*rate;
} else {
ImgD.width = image.width;
ImgD.height =image.height;
}
}
}
</script>
</head>
<body>
<img src="http://www.baidu.com/images/logo.gif"onload=proDownImage(this); />
</body>
</html>