页面中嵌入了Flash时滚动条问题
用于解决在页面中嵌入了Flash时滚动条问题的处理
初始化加入以下代码:
stage.addEventListener(MouseEvent.MOUSE_OVER,function (e:MouseEvent):void{ExternalInterface.call("eval","if(navigator.userAgent.indexOf ('Firefox')>0){var __on_flash_wheel=function(e){e.preventDefault(); e.stopPropagation();};window.addEventListener('DOMMouseScroll', __on_flash_wheel, false);}else{document.onmousewheel=function(){return false;};}");}); stage.addEventListener(MouseEvent.MOUSE_OUT,function(e:MouseEvent):void {ExternalInterface.call("eval","if (navigator.userAgent.indexOf('Firefox')>0){window.removeEventListener ('DOMMouseScroll', __on_flash_wheel, false);}else {document.onmousewheel=null;}");});
或者扔在FLASH体外:
<script language="JavaScript" type="text/javascript"> var isFF = navigator.userAgent.toLowerCase().indexOf('firefox'); var mousewheel=function(event) { var event = event ? event : window.event; var obj = event.srcElement; if (!obj) { obj = event.target; }
//此处可以加入判断,来实现类似百度文库的效果,先把浏览器滚动条移至可以完全显示flash的位置,然后再操作flash内部滚动条
if(obj.type == "application/x-shockwave-flash" || obj.type == "") { if(isFF > 0) { event.preventDefault(); event.stopPropagation(); } else { return false; } } } function onloaded() { if(isFF > 0) document.body.addEventListener("DOMMouseScroll", mousewheel, false); else document.body.onmousewheel=mousewheel; } window.onload = function() { onloaded(); } </script>
如果是嵌入的FlexPaper,需要对FlexPaper的内部代码进行修改,因为FlexPaper内部会在加载时往页面上加载部分代码,导致浏览器滚动条不失效,MacMouseWheelHandler类