在Flash对象内滚动时防止网页滚动 [英] Prevent webpage from scrolling when scrolling inside a Flash object

查看:173
本文介绍了在Flash对象内滚动时防止网页滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个嵌入在一个long对象中的Flash对象网页。我在Flash中侦听MOUSE_WHEEL事件,并相应地滚动我的Flash内容。但是,当我滚动Flash对象时,网页也滚动。

有什么办法可以防止这种行为,即当Flash对象有锁定网页的滚动位置焦点?我不希望使用JavaScript。

解决方案

我不认为没有JavaScript,这是不可能的。

您需要使用

  

code> if(window.addEventListener)
/ ** DOMMouseScroll用于mozilla。 * /
window.addEventListener('DOMMouseScroll',handleWheelEvent,false);
/ ** IE / Opera。 * /
window.onmousewheel = document.onmousewheel = handleWheelEvent;

函数handleWheelEvent(e){
e.preventDefault();
}


I'm sure this must be a common question, but I haven't found an answer elsewhere.

I've got a Flash object embedded in a long webpage. I listen for the MOUSE_WHEEL event in Flash, and scroll my Flash content accordingly. However, when I scroll over the Flash object, the webpage also scrolls.

Is there any way to prevent this behaviour, i.e. lock the webpage's scrolling position when the Flash object has focus? I'd prefer not to have to use JavaScript.

解决方案

I don not think this is possible without JavaScript.

You would need to communicate from the Flash movie to the browser using ExternalInterface whenever the Flash movie changes focus.

Then, have a JavaScript function on the page trap and eat the mousewheel event:

if (window.addEventListener)
    /** DOMMouseScroll is for mozilla. */
    window.addEventListener('DOMMouseScroll', handleWheelEvent, false);
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = handleWheelEvent;

function handleWheelEvent(e){
    e.preventDefault();
}

这篇关于在Flash对象内滚动时防止网页滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆