您的位置:首页 > 其它

通过自建iframe遮罩层解决flash位于window窗口之上的问题

2011-01-12 10:19 876 查看
效果对于固定不动窗口或菜单则更有效,并不太适用于可移动的窗口,遮罩层与窗口位置很难一致。若是可移动的窗口建议用前面一篇文章所介绍的shim属性Ext自身提供的方法。

同样下面的方法只对IE有效,firefox下依然无效。

Ext.onReady(function() {
......
//创建垫片效果iframe遮罩层
function createShim(coordinate) {
closeShim();
var shimmer = document.createElement('iframe');
shimmer.id='shimmer';
shimmer.style.position='absolute';
shimmer.style.top=coordinate.top;
shimmer.style.left=coordinate.left;
shimmer.style.width=coordinate.width;
shimmer.style.height=coordinate.height;
shimmer.style.zIndex='999';
shimmer.setAttribute('frameborder','0');
// shimmer.setAttribute('src','javascript:false;');
document.body.appendChild(shimmer);
}
//移除iframe遮罩层
function closeShim(){
var shimmer = document.getElementById('shimmer')
if(shimmer){
document.body.removeChild(shimmer);
}
}
// 查询窗口对象变量
var searchWin;
// 查询按钮
function doSearch_pic_panel() {
searchWin = Ext.getCmp('search-window'); //避免出现显示两个窗口的问题

if (!searchWin) {
searchWin = new Ext.Window({
contentEL:'search-window',
title : '请输入查询条件',
layout : 'fit',
width : 400,
height : 300,
closeAction : 'hide',
plain : true,
floating:true,
shim:true,
items : searchFormPanel_pic_panel,
buttons : [{
text : '查询',
handler : function() {

searchWin.hide();
}
}, {
text : '关闭',
handler : function() {
searchWin.hide();
}
}]
});
searchWin.on("show",function(window){
var winEl = window;
var position =new Array();
position = winEl.getPosition(true);
createShim({
top:position[1],
left:position[0],
width:winEl.getFrameWidth()+winEl.getInnerWidth(),
height:winEl.getFrameHeight()+winEl.getInnerHeight()
});
});

searchWin.on("hide",function(window){
closeShim();
});
searchWin.on("beforemove",function(component,x,y){
closeShim();
});
searchWin.on("move",function(component,x,y){
closeShim();
var winEl = Ext.getCmp('search-window');
var position =new Array();
position = winEl.getPosition(true);
createShim({
top:y,
left:x,
width:winEl.getFrameWidth()+winEl.getInnerWidth(),
height:winEl.getFrameHeight()+winEl.getInnerHeight()
});
});
}
searchWin.show();
}
......

}

其实贴出来主要是学习这一种思想。网上也有关于该问题的讨论:

Why does moving the IFRAME shim slow things down?

链接地址:https://www.extjs.com/forum/showthread.php?1384-Why-does-moving-the-IFRAME-shim-slow-things-down

Iframe Shim解决applet挡住ExtJS工具栏菜单问题

链接地址:http://agile-boy.javaeye.com/blog/140935

[OPEN-884] Shim size problem on Ext.Window with shadow

链接地址:http://www.extjs.com/forum/showthread.php?97413-OPEN-884-Shim-size-problem-on-Ext.Window-with-shadow&p=459829#post459829

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/foamflower/archive/2010/04/21/5512865.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐