Javascript:关闭父窗口后无法访问对象
因此,我有一个父窗口,它将自己打开到一个新窗口,只是为了删除状态栏、工具栏等。关闭父窗口后,传递的变量返回空字符串。有时它会返回以下错误消息:远程服务器计算机不存在或不可用。即使在关闭父窗口之后,我也确实需要访问此变量。有什么建议吗Javascript:关闭父窗口后无法访问对象,javascript,jquery,internet-explorer-8,Javascript,Jquery,Internet Explorer 8,因此,我有一个父窗口,它将自己打开到一个新窗口,只是为了删除状态栏、工具栏等。关闭父窗口后,传递的变量返回空字符串。有时它会返回以下错误消息:远程服务器计算机不存在或不可用。即使在关闭父窗口之后,我也确实需要访问此变量。有什么建议吗 var _env = {}; $(window).load(function() { /** * * If initialization was not yet performed, start the initialization.
var _env = {};
$(window).load(function()
{
/**
*
* If initialization was not yet performed, start the initialization.
* Otherwise, show application.
*
**/
if (window.opener)
{
/* Start transition to the new window */
window.blur();
_env = window.opener._env;
console.log(_env["title"]);
/* Show system */
window.opener.close();
window.focus();
console.log(_env["title"]); // Returns blank
}
else
{
/* Some process manipulating the '_env' variable */
/* .... */
/* .... */
window.open("./index.html", _env["title"], "directories=0, menubar=0, toolbar=0, titlebar=0, resizable=1, width=" + _env["winWidth"] + ", height=" + _env["winHeight"]);
window.focus();
window.open("","_self", ""); // To prevent prompt on closing..
}
});
您可以将对象转换为JSON,并将window.location.href设置为该对象。然后,您可以在需要数据时提取它,引用不会出现任何问题,因为您正在创建一个新对象