onmousewheel是鼠標滾輪事件,是IE6的對象的新事件;style.zoom,event.wheelDelta是IE6的對象的新屬性,style.zoom是變大縮小,未賦值前返回null,賦值成XX%,就變化爲XX%,並返回XX%;event.wheelDelta是滾輪滾動一下的角度,上滾一下爲120,下滾一下爲-120。javascript
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML>
- <HEAD>
- <TITLE> New Document </TITLE>
- <script language="JavaScript">
- <!--
- //改變圖片大小
- function resizepic(thispic)
- {
- if(thispic.width>700) thispic.width=700;
- }
- //無級縮放圖片大小
- function bbimg(o)
- {
- var zoom=parseInt(o.style.zoom, 10)||100;
- zoom+=event.wheelDelta/12;
- if (zoom>0) o.style.zoom=zoom+'%';
- return false;
- }
- -->
- </script>
- </HEAD>
- <BODY>
- <IMG onmousewheel="return bbimg(this)" height=439 src="http://tech.lmtw.com/UploadFiles/200702/20070227133622544.jpg" width=520 onload=javascript:resizepic(this) border=0>
- <br><br>
- <img src='http://www.blueidea.com/img/common/logo.gif' onMouseWheel="this.style.zoom*= Math.pow(.9,Math.abs(event.wheelDelta)/event.wheelDelta);" onClick="this.style.zoom=1;" style="zoom=1;" />
- </BODY>
- </HTML>