比較方便的onMouseWheel縮放圖片效果 原創(chuàng)
原創(chuàng) 更新時(shí)間:2006年09月06日 00:00:00 原創(chuàng) 作者:
復(fù)制代碼 代碼如下:
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>onMouseWheel縮放圖片效果-www.dbjr.com.cn</TITLE>
<body>
<script>
function bbimg(o)
{
var zoom=parseInt(o.style.zoom, 10)||100;
zoom+=event.wheelDelta/12;
if (zoom>0) o.style.zoom=zoom+'%';
}
function addthis()
{
var e=window.event?window.event:e;
var srcE=e.srcElement?e.srcElement:e.target;
if(!srcE) return;
//author:reterry(dxy) www.dbjr.com.cn歡迎轉(zhuǎn)載,轉(zhuǎn)載時(shí)請(qǐng)寫明出處。
if (String(srcE.tagName).toLowerCase()=='img'){
//alert('好');
bbimg(srcE)
}
}
function backthis(){
var e=window.event?window.event:e;
var srcE=e.srcElement?e.srcElement:e.target;
if(!srcE) return;
//author:reterry(dxy) www.dbjr.com.cn歡迎轉(zhuǎn)載,轉(zhuǎn)載時(shí)請(qǐng)寫明出處。
if ((String(srcE.tagName).toLowerCase()=='img')&&(window.event.ctrlKey)){
//alert('好');
srcE.style.zoom='100%';
}}
document.onmousewheel=addthis;
document.onmouseout=backthis;
</script>
<A id=ImgSpan href="http://www.dbjr.com.cn/logos.gif" target=_blank><IMG src="http://www.dbjr.com.cn/logos.gif" border=0></A>
<br>鼠標(biāo)滑輪滾動(dòng)查看效果,Author:reterry(dxy) www.dbjr.com.cn歡迎轉(zhuǎn)載,轉(zhuǎn)載時(shí)請(qǐng)寫明出處。<br>按住ctrl鍵然后鼠標(biāo)從圖片上移開,圖片可恢復(fù)原始大小</body></html>
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁(yè)面才能執(zhí)行]
相關(guān)文章
javascript實(shí)現(xiàn)圖片切換的幻燈片效果源代碼
網(wǎng)頁(yè)上有許多圖片切換的幻燈片效果,它們大多用flash實(shí)現(xiàn),那javascript能不能實(shí)現(xiàn)他們呢,當(dāng)然可以,我自己寫了一個(gè),需要的朋友可以參考下2012-12-12常見JS效果之圖片減速度滾動(dòng)實(shí)現(xiàn)代碼
圖片減速度滾動(dòng),一般用于產(chǎn)品的展示效果。作為前端,互聯(lián)網(wǎng)上一些常見效果都要嘗試去實(shí)現(xiàn),不能因?yàn)楣居貌坏骄筒蛔觥?/div> 2011-12-12最新評(píng)論