主题:[讨论]高手帮我看看
高手帮我看看,我希望修改下面的代码,做到:
如果原图宽度大于680,不管多大,放大的宽度极限就是680。
如果原图小于680,最大放大宽度不能超过原图宽度。
<script language="JavaScript">
var zoomLevel = 0;
var currentWidth = 0;
var currentHeight = 0;
var originalWidth = 0;
var originalHeight = 0;
function initial(){
currentWidth = document.myImage.width;
currentHeight = document.myImage.height;
originalWidth = currentWidth;
originalHeight = currentHeight;
update();
}
function zoomIn(){
document.myImage.width = currentWidth*2;
document.myImage.height = currentHeight*2;
zoomLevel = zoomLevel + 1;
update();
}
function zoomOut(){
document.myImage.width = currentWidth/2;
document.myImage.height = currentHeight/2;
zoomLevel = zoomLevel - 1;
update();
}
</script>
<body onload="initial()">
<img name="myImage" src="http://www.7788ok.com/UpLoadFiles/200512101083980752.jpg">
<input type="button" value="放大图片" onclick="zoomIn()">
<input type="button" value="缩小图片" onclick="zoomOut()">
如果原图宽度大于680,不管多大,放大的宽度极限就是680。
如果原图小于680,最大放大宽度不能超过原图宽度。
<script language="JavaScript">
var zoomLevel = 0;
var currentWidth = 0;
var currentHeight = 0;
var originalWidth = 0;
var originalHeight = 0;
function initial(){
currentWidth = document.myImage.width;
currentHeight = document.myImage.height;
originalWidth = currentWidth;
originalHeight = currentHeight;
update();
}
function zoomIn(){
document.myImage.width = currentWidth*2;
document.myImage.height = currentHeight*2;
zoomLevel = zoomLevel + 1;
update();
}
function zoomOut(){
document.myImage.width = currentWidth/2;
document.myImage.height = currentHeight/2;
zoomLevel = zoomLevel - 1;
update();
}
</script>
<body onload="initial()">
<img name="myImage" src="http://www.7788ok.com/UpLoadFiles/200512101083980752.jpg">
<input type="button" value="放大图片" onclick="zoomIn()">
<input type="button" value="缩小图片" onclick="zoomOut()">