现在在公司做一个项目,用到ext,我先用这段代码[code="js"]function showANewWindow(url,title){
topWin= new top.Ext.Window({
id:'topWindow',
title:title,
width:650,
height: 450,
resizable:true,
constrain :true,
plain :true,
autoScroll :true,
maximizable :true,
modal: true,
html:''
});
topWin.show();
}[/code]弹出一个窗口!
然后在这个窗口里面载入一个jsp页面,在这个jsp页面里面有一个[code="js"]Ext.onReady(function(){
var i = document.getElementById("i");
alert(i.value);
//window.moveTo(1500, 1500);
});[/code] 这样的代码,页面载入时就自动触发,然后拿到i后,想做一个判断,如果符合判断的话,就弹出一个alert("warning");然后把上面弹出来的窗口给关闭掉,我可以肯定i是可以拿到的,但无论我用window.close();还是window.parent.document.getElementById("");窗口ID我没有找到!
我想问下,该如何才可以把我这个弹出来的窗口关闭掉呢?
Ext中Window,不是真正的Window,而是用div模拟出的窗口,因此一般只是隐藏掉,如果非要关闭掉,就需要从document中移除window对应的dom元素,即id为'topWindow'的元素
[code="java"]
Ext.getCmp('topWindow').hide();
[/code]
首先,如果想关掉这个window,需要加属性closeAction:'close',否则就是调用close方法,window还是隐藏的
其次如果showANewWindow需要经常调用,
建议不要将window关闭,隐藏就行,同时window对象创建移到外面,
调用时设置url和title就行
document.getElementById(this.frameId).src=url;
window.setTitle(title);
这哥们,应该是做桌面程序过来的吧!