但是用的onclick事件,所以点击一下,就放大或者缩小一点.
来源:http://www.85flash.com/Get/JavaScript/2006-8-17/115327705.htm
<script language="javascript">
var oTime;
function chgSize(args) {
var oImg = document.all['oImg'];
oImg.style.zoom = parseInt(oImg.style.zoom) + (args ? +1 : -1) + '%';
oTime = window.setTimeout('chgSize(' + args + ')', 100);
}
document.onmouseup = function() {
window.clearTimeout(oTime);
}
</script>
<div style="height: 200px; overflow: auto;">
<img id="oImg" src="/Files/BeyondPic/2006-8/14/28youandi.jpg" style="zoom: 100%;">
</div>
<button onmousedown="chgSize(true);" onmouseup="window.clearTimeout(oTime);">↑</button>
<button onmousedown="chgSize(false);" onmouseup="window.clearTimeout(oTime);">↓</button>
var oTime;
function chgSize(args) {
var oImg = document.all['oImg'];
oImg.style.zoom = parseInt(oImg.style.zoom) + (args ? +1 : -1) + '%';
oTime = window.setTimeout('chgSize(' + args + ')', 100);
}
document.onmouseup = function() {
window.clearTimeout(oTime);
}
</script>
<div style="height: 200px; overflow: auto;">
<img id="oImg" src="/Files/BeyondPic/2006-8/14/28youandi.jpg" style="zoom: 100%;">
</div>
<button onmousedown="chgSize(true);" onmouseup="window.clearTimeout(oTime);">↑</button>
<button onmousedown="chgSize(false);" onmouseup="window.clearTimeout(oTime);">↓</button>
来源:http://www.85flash.com/Get/JavaScript/2006-8-17/115327705.htm
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2117/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表