打开和关闭JavaScript窗口 [英] open and close javascript window
本文介绍了打开和关闭JavaScript窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想关闭一个浏览器窗口,无论它在打开
中。是新的JavaScript的,所以帮助我创建使用JavaScript的以下逻辑。我的JavaScript代码在这里:
if(myWindow.open()== true){
myWindow.close );
} else {
myWindow = window.open('http://index.html',
'popUpWindow',
'height = 700,width = 800,left = 10,top = 10,resizable = yes,scrollbars = yes,toolbar = yes,menubar = no,location = no,directories = no,status = yes'
);
解决方案使用
closed
属性来检查窗口状态,但首先检查窗口对象是否已创建。 var myWindow = null;
if(myWindow&!myWindow.closed){// exists and not closed
myWindow.close();
myWindow = null; //删除对象
} else {//不存在或被关闭
myWindow = window.open('http://index.html',$ b $'popUpWindow',
'height = 700,width = 800,left = 10,top = 10,resizable = yes,scrollbars = yes,toolbar = yes,menubar = no,location = no,directories = no,status = yes'
);
}
I want to close a browser window whether it is in open
. Am new for javascript so help me to create the below logic using javascript. My JavaScript code is here:
if (myWindow.open() == true) {
myWindow.close();
} else {
myWindow=window.open('http://index.html',
'popUpWindow',
'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes'
);
}
解决方案
Use closed
property to check the window status, but first check whether the window object has been created or not.
var myWindow=null;
if (myWindow && !myWindow.closed) { //exist and is not closed
myWindow.close();
myWindow=null; //delete the object
} else { //not exist or is closed
myWindow=window.open('http://index.html',
'popUpWindow',
'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes'
);
}
这篇关于打开和关闭JavaScript窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文