用flexpaper+swfobject实现在线预览,预览的时候在flash区域需要弹出div层做别的事情。最初div层被flash遮盖住了,设置了params.wmode = "opaque"后div层确实可以在flash上面,但flash的滚动条不能滚动。借鉴了http://www.oschina.net/question/5189_28611的代码,搞定了这个问题。
window.onload = function(){
if (window.addEventListener) {
window.addEventListener('DOMMouseScroll', deltaDispatcher, false);
}
document.body.onmousewheel = deltaDispatcher;
}
function deltaDispatcher(event){
event = window.event || event;
var delta = 0;
if (event.wheelDelta) {
delta = event.wheelDelta/120;
if (window.opera){
delta = -delta;
}
} else if (event.detail) {
delta = -event.detail;
}
if (event.preventDefault){
event.preventDefault();
}
var obj = swfobject.getObjectById("FlexPaperViewer");
if(typeof( obj.externalMouseEvent ) == 'function'){
obj.externalMouseEvent(delta);
}
}