Article Detail

onmousewheel event 缩放图片效果

onMouseWheel Event Sample-www.51windows.Net var count = 10; function Picture() {...

HTML 阅读 15.1万 5 分钟阅读 2015-10-14 16:57
GDScript3
48 行
<HTML>  
<HEAD>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
<TITLE>onMouseWheel Event Sample-www.51windows.Net</TITLE>  
<SCRIPT>  
var count = 10;  
function Picture()  
{  
count = Counting(count);  
Resize(count);  
return false;  
}  
function Counting(count){  
if (event.wheelDelta >= 120)  
count++;  
else if (event.wheelDelta <= -120)  
count--;  
return count;  
}  
function Resize(count){  
oImage.style.zoom = count + '0%';  
oCounter.innerText = count + '0%';  
}  
</SCRIPT>  
</HEAD>  
<BODY>  
<h1>onmousewheel event</h1>  
<P>  
This sample uses the onmousewheel event to expand or contract the picture below. 

  
Move the cursor over the picture and roll the mouse wheel up and down.</P>  
<span style="font-weight:bold">Size =  
<span id="oCounter" style="color:red;">100%</span></span>  

  
<img id="oImage" src="http://www.jb51.net/logos.gif" onmousewheel="return Picture();" >  

  

  

  
<A HREF="http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/onmousewheelEX.htm" target="_blank">http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/onmousewheelEX.htm</A>.  
</BODY>  
</HTML>  
<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">  
<input type="button" name="Button" value="查看源代码" onClick= 'window.location = "view-source:" + window.location.href'></div> 
GDScript3
37 行
<HTML>   
<HEAD>   
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">   
<TITLE>onMouseWheel缩放图片效果-www.jb51.Net</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.jb51.net欢迎转载,转载时请写明出处。 
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.jb51.net欢迎转载,转载时请写明出处。 
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.jb51.net/logos.gif" target=_blank><IMG src="http://www.jb51.net/logos.gif" border=0></A> 
<br>鼠标滑轮滚动查看效果,Author:reterry(dxy) www.jb51.net欢迎转载,转载时请写明出处。<br>按住ctrl键然后鼠标从图片上移开,图片可恢复原始大小</body></html>
Comments 评论区
评论区 当前文章还没有公开评论
Comment Form 留下评论
正在回复 #0
粘贴图片、拖拽文件,或点上面的按钮上传 图片会自动插入 [img] 标签,其他附件会自动插入 [attach] 标签。
正在上传...
提交前会先拉起旧项目同款第三方人机验证。

不再要求填写昵称;reply 会生成一条带楼层回链的新评论,quote 会附带完整引用块,并保持评论锚点跳转。

lizhenqiu blog is powered by lizhenqiu.com Version 6.9

Processed in 0.0139 second(s) W3C

本博客的所有原创作品采用 知识共享 署名-非商业性使用-相同方式共享 2.5 协议 进行许可

本站由 七七牛 云存储 阿阿里云 计算与安全服务 拍又拍云 CDN 加速 百百度智能 AAMH 布布集网 AI指南针AI

桂公网安备 45010302000998号 桂ICP备15007619号-1 中国互联网举报中心 建议使用谷歌浏览器浏览
Navigation 文章导航
⌂ ↓ ↑
100%
图片预览
Gallery 图集
0 张图片

正在整理正文和评论里的图片。

当前页还没有可展示的图片。
Quick Comment 快速评论

直接输入内容,提交时仍会走当前页面的人机验证。

正在上传...
操作提示