效果对于固定不动窗口或菜单则更有效,并不太适用于可移动的窗口,遮罩层与窗口位置很难一致。若是可移动的窗口建议用前面一篇文章所介绍的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
标签:function,遮罩,flash,Ext,shimmer,searchWin,window,winEl From: https://blog.51cto.com/u_2544485/7395586