1

所以我有一个父窗口,它打开一个新窗口(只是为了删除状态栏、工具栏等)。关闭父窗口后,传入的变量返回空白字符串。有时它会返回此错误消息:“远程服务器计算机不存在或不可用。” 即使在关闭父窗口后,我也确实需要访问此变量。有什么建议么?

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..
    }
});
4

1 回答 1

0

您可以将对象转换为 JSON,并设置window.location.href为它。然后,您可以在需要数据时提取它,并且引用不会有任何问题,因为您正在创建一个新对象。

于 2012-11-25T08:49:09.727 回答