我有一个 Java 项目,使用 Java 脚本来管理站点。我有一个打开帮助对话框弹出窗口的功能。当我刷新主页时,弹出窗口没有关闭,它仍然打开。我有一个保护,您可以在帮助下打开 2 个窗口,但它正在使用处理程序 (helpWnd),在刷新主页时它会丢失。
对不起我的英语不好; )
var helpWnd = null;
// Open help dialog with url from recived helpId
function openHelpDialog(helpId, height, width, title) {
var url;
if(helpId == "contact") {
url = "help/contact.html";
} else {
var regularExpression = /[a-zA-Z][a-zA-Z][a-zA-Z][0-9][0-9][0-9][0-9]/;
if(helpWnd!=null) {
helpWnd.close();
}
url = "help/index.html?"+helpId.toLowerCase()+".html";
if(!regularExpression.test(helpId)) {
url = "help/index.html";
}
}
helpWnd = window.open(url, title, 'width=1000, height=600, menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=yes, status=no');
}
//this refresh main page
function changeRole(roleName,redirectUrl) {
dojo.xhrPost({
content: {
role: roleName
},
handleAs: "json",
sync: true,
url: 'someUrl.npi',
load: function (response) {
dojo.cookie(response.cookieHash, response.role, {expires : response.cookieExpiryTime});
document.location.href = redirectUrl;
}
});
}