Hello guys,
sorry for have wasted your time. My testcase that I provided was not really showing the issue. It very obvious why the code I provided above is wrong. Doh.
Anyway, I now have an example that shows the problem I was having. Basically an object is no longer instanceof Object when it is passed to another window.
Main window html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
window.onload = function()
{
window.open("popup.html", "", "width=200, height=200");
}
function checkIfObject(oTest)
{
var sMsg = "Object passed to main window. Instance of Object == ";
var bIsObject = oTest instanceof Object;
alert(sMsg + bIsObject); // this will alert false
}
</script>
</head>
<body>
</body>
</html>
Popup window html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Popup</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function checkIfObject(oTest)
{
var sMsg = "Car object created. Instance of Object == ";
var bIsObject = oTest instanceof Object;
alert(sMsg + bIsObject); // this will alert true
}
var oCar = new Object();
oCar.color = "red";
oCar.amountOfDoors = 4;
checkIfObject(oCar);
opener.checkIfObject(oCar);
</script>
</head>
<body>
</body>
</html>
Due to this, we had to use the JSON.stringify(oMyObj) method (see json.org) to pass object between windows... Would be interesting to know why this doesn't really work.
What is interesting is that I can access the properties of the object. Odd.
Regards,
/José Jeria