fly512
(我本如是)
版主
  
人生的另一半
UID 42566
精华
0
积分 2510
帖子 2397
金钱 1780 喜悦币
威望 0
人脉 730
阅读权限 100
注册 2004-10-31 来自 亚特兰迪斯
状态 离线
|
[推荐阅读] 求职帖:找个PHP工作
<?php <script type="text/javascript"> var zoomLevel = 0; var originalWidth = 0; var originalHeight = 0; var maxWidth = 680;//宽度最大值 function initial(){ var imgObj = new Image(); imgObj.src = document.myImage.src; originalWidth = imgObj.width; originalHeight = imgObj.height; maxWidth = originalWidth > maxWidth ? maxWidth : originalWidth; updateImg(); } function zoomIn(){ zoomLevel++; updateImg(1); //update(); } function zoomOut(){ zoomLevel--; updateImg(0); //update(); } function updateImg(type) { if( type == 0) {//缩小 while( true) {//请弄个表较大的图片测试(w:1024的) var leval = Math.pow(2, zoomLevel); alert(leval);//请将此行注释 if( originalWidth*leval > document.myImage.width) { zoomLevel--; } else { break; } } } else { var leval = Math.pow(2, zoomLevel); } if(originalWidth*leval <= maxWidth) { document.myImage.width = originalWidth*leval; document.myImage.height = originalHeight*leval; } else { document.myImage.width = maxWidth; document.myImage.height = (originalHeight/originalWidth)*maxWidth; } }
</script> ?>
|  不要使用数据库
PHP中国 |
|