The open() method creates a new secondary browser window, similar to choosing New Window from the File menu. The strUrl parameter specifies the URL to be fetched and loaded in the new window. If strUrl is an empty string, then a new blank, empty window (URL about:blank) is created with the default toolbars of the main window.
Note that remote URLs won't load immediately. When window.open() returns, the window always contains about:blank. The actual fetching of the URL is deferred and starts after the current script. block finishes executing. The window creation and the loading of the referenced resource are done asynchronously.
解决方法:
function openMenuUrl(url, windowId){
if(windowId){
windowId = windowId + cs2_generateTempId(windowId);
var scalar = 0.9;
var w_ht = Math.round(scalar * screen_ht);
var w_wd = Math.round(scalar * screen_wd);
var w_left = Math.round((screen_wd-w_wd)*0.5);
var w_top = Math.round((screen_ht-w_ht)*0.5);
windowparms = "resizable=yes,status=yes,scrollbars=yes,";
windowparms += "left=" + w_left + ",top=" + w_top + ",screenX=" + w_left + ",screenY=" + w_top + ",";
windowparms += "height=" + w_ht + ",width=" + w_wd + ",toolbar=no";
if (isStandardZoneFunction(url)){
window.open("../transition.htm", windowId, windowparms);
} else if(url.indexOf("cs1MocToMcc=true") == -1){
window.open("../progress.htm", windowId, windowparms);
}
setTimeout(function() {
if((myNewWin=window.open(url,windowId,windowparms))==null) {
return;
}
myNewWin.focus();
}, 1000);
var_proceed=true;
} else{
window.location.href = url;
}
}
此处用到了setTimeout与闭包。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8520577/viewspace-754948/ ,如需转载,请注明出处,否则将追究法律责任。