标签:
最近做一个项目,需要使用flexpaper来做pdf在线浏览,但是每当鼠标滚轮在flash部位滚动的时候,整个页面也开始滚动起来,特别是chrome浏览器更是坑爹,花了好半天才找出勉强解决的方法,分享一下代码,如有更好的解决方案,求求给我建议。
1 var isFF = window.navigator.userAgent.toLowerCase().indexOf(‘firefox‘); 2 var isChrome = window.navigator.userAgent.indexOf("Chrome"); 3 var mousewheel=function(event) 4 { 5 var event = event ? event : window.event; 6 var obj = event.srcElement || event.target; 11 if(obj.type == "application/x-shockwave-flash" || obj.type == ""){ 12 if(document.all){ 13 event.cancelBubble = true; 14 event.returnValue = false; 15 }else if(isChrome>0){ 16 document.body.style.overflow="hidden"; 17 event.stopPropagation(); 18 }else{ 19 event.preventDefault(); 20 event.stopPropagation(); 21 } 22 } 23 } 24 25 function onloaded(){
document.getElementsByTagName(‘object‘)[0].setAttribute(‘tabindex‘,‘-1‘);
8 document.getElementsByTagName(‘object‘)[0].onmouseover = function(){
9 this.setAttribute(‘tabindex‘,‘-1‘);
10 } 26 if(isFF > 0){ 27 document.body.addEventListener("DOMMouseScroll", mousewheel, false); 28 }else if(isChrome >0){ 29 document.body.style.overflow="hidden"; 30 document.getElementsByTagName(‘object‘)[0].onmousewheel=mousewheel; 31 document.body.onmousewheel = function(){ 32 document.body.style.overflow=‘auto‘; 33 } 34 document.body.onclick = function(){ 35 document.body.style.overflow=‘auto‘; 36 } 37 }else{ 38 document.body.onmousewheel=mousewheel; 39 } 40 } 41 42 window.onload = function(){ 43 onloaded(); 44 }
标签:
原文地址:http://www.cnblogs.com/zhenwoo/p/4612184.html