我在关闭弹出窗口时遇到问题。我的问题是独一无二的,如果我从父母点击退出,它会关闭所有窗口,但是当我从一个孩子退出时,我将从Parent注销,因此它不会关闭其他打开的子窗口。
当我从一个孩子退出然后我从父母退出时,我检查了控制台,它没有进入if块。
当我从子窗口和父窗口注销时之间唯一的区别是,如果我从父窗口注销,它将关闭所有窗口并重定向父窗口,如果我从子窗口注销,它将在父窗口创建模式对话框,并显示消息会话超时。
当我从孩子退出时,我从服务器获得Invalid Session Id passed
然后我正在调用函数
showModalBoxForInvalidSessionInfo
当我在控制台中检查时,我没有得到awin和bwin变量值。他们设置为undefined。但如果我直接调用onLogout函数,它将获得实际值。
我无法理解为什么即使我将其声明为一个全局变量,为什么价值不会进入内部有什么不同。
我正在粘贴我的JS文件以获取参考
var userName;
var sessionId;
var userName;
var userId;
var awin;
var bwin;
$(document).ready(
function() {
userName = getURLParameters('userName');
sessionID = getURLParameters('requestID');
userId = getURLParameters('userId');
var welcomeMsg = document.getElementById('welcomeMsg');
var text = document.createTextNode('Welcome ' + userName );
var img = document.createElement('img');
img.style.height = '16px';
img.style.width = '16px';
img.src = 'images/arrow.png';
welcomeMsg.appendChild(text);
welcomeMsg.appendChild(img);
//style="width:16px; height:16px;"
console.log("Ready");
var fullAuthUrl = authorizationUrl
+ "?requestType=getRoles&username=" + userId
+ "&requestID=" + sessionID;
console.log(fullAuthUrl);
jQuery.support.cors = true;
$.ajaxSetup({
cache : false
});
$.ajax({
url : fullAuthUrl,
dataType : 'text',
crossOrigin : true,
cache : false,
type : 'GET',
success : function(response) {
//console.log("Success");
var responseBodyFull = response.replace(/^\s+|\s+$/g, '');
//responseBodyFull = response;
if (responseBodyFull == "Invalid Session Id passed") {
console.log("Invalid Session");
showModalBoxForInvalidSessionInfo();
}
console.log(responseBodyFull);
enableOrDisableLinks(responseBodyFull);
}
});
});
function b() {
sessionId = getURLParameters('requestID');
userName = getURLParameters('userName');
userId = getURLParameters('userId');
lvalue = getURLParameters('lValue');
lver = getURLParameters('lVer');
window.name = "parent";
var intWidth = screen.width - 10; //Adjust for the end of screen
var intHeight = screen.height - 80; //Adjust for the Icon Bar at the bottom of the window.
var strWinProp = " toolbar=no" //Back, Forward, etc...
+ ",location=no" //URL field
+ ",directories=no" //"What's New", etc...
+ ",status=yes" //Status Bar at bottom of window.
+ ",menubar=no" //Menubar at top of window.
+ ",resizable=yes" //Allow resizing by dragging.
+ ",scrollbars=yes" //Displays scrollbars is document is larger than window.
+ ",titlebar=yes" //Enable/Disable titlebar resize capability.
+ ",width="+intWidth //Standard 640,800/788, 800/788
+ ",height="+intHeight //Standard 480,600/541, 600/566
+ ",top=0" //Offset of windows top edge from screen.
+ ",left=0" //Offset of windows left edge from screen.
+ "";
bwin = window.open(bUrl + userName + "&requestID=" + sessionId
+ "&userId=" + userId,'_blank',strWinProp);
}
function a() {
sessionId = getURLParameters('requestID');
userName = getURLParameters('userName');
userId = getURLParameters('userId');
lvalue = getURLParameters('lValue');
lver = getURLParameters('lVer');
window.name = "parent";
var intWidth = screen.width - 10; //Adjust for the end of screen
var intHeight = screen.height - 80; //Adjust for the Icon Bar at the bottom of the window.
var strWinProp = " toolbar=no" //Back, Forward, etc...
+ ",location=no" //URL field
+ ",directories=no" //"What's New", etc...
+ ",status=yes" //Status Bar at bottom of window.
+ ",menubar=no" //Menubar at top of window.
+ ",resizable=yes" //Allow resizing by dragging.
+ ",scrollbars=yes" //Displays scrollbars is document is larger than window.
+ ",titlebar=yes" //Enable/Disable titlebar resize capability.
+ ",width="+intWidth //Standard 640,800/788, 800/788
+ ",height="+intHeight //Standard 480,600/541, 600/566
+ ",top=0" //Offset of windows top edge from screen.
+ ",left=0" //Offset of windows left edge from screen.
+ "";
awin = window.open(aUrl + userName + "&requestID=" + sessionId + "&userId="
+ userId,'_blank',strWinProp);
}
function showModalBoxForInvalidSessionInfo(){
$("#modelView").dialog({
autoOpen : false,
modal : true,
buttons : [ {
text : "OK",
icons : {
primary : "ui-icon-heart"
},
click : function() {
$(this).dialog("close");
}
}]
});
$("#modelView" ).dialog("open");
$("#modelView").text("Session Timed Out");
}
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //To support the browsers IE7+, Firefox, Chrome, Opera, Safari
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); // For the browsers IE6, IE5
} else {
alert("Error due to old verion of browser upgrade your browser");
}
}
function onLogout(){
if (awin && !awin.closed) {
awin.close();
}
if (bwin && !bwin.closed) {
bwin.close();
}
window.location = loginPageUrl;
}
HTML文件非常简单,有两个按钮调用函数a和函数b以及调用函数onLogout的菜单。
有人请帮帮我。