So I have a parent window who is opening itself to a new window (just to remove the status bar, toolbar, others). After closing the parent window, the passed variable return blank string. Sometimes it returns this error message: “The remote server machine does not exist or is unavailable.” I really need to access this variable even after closing the parent window. Any suggestions?
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..
}
});
You can convert the object to JSON, and set
window.location.hrefto it. You can then extract it when you need the data, and there won’t be any issues with references because you’re creating a new object.