Question

I have a button which opens up a child window with a list of Images which the user can click which sends values in parameters to a function where it put the parameters in an array value to variable that has been created in the parent window and then closes the child window. The current code I have works in Chrome and Firefox but doesn't work in IE for some reason of which I do not have knowledge to know! I would preferably want it to work in up to IE 7 if that's possible, although at the current moment it doesn't even work in IE 9.

Parent Window Code:

var edge;

function getEdgeProfile(){
    myEdge = window.open('edge.html','','top=50,left=50,width=400,height=400');
}

Child Window Code:

<head>
<script>

function selectEdge(name, price, type){
    opener.edge = [name, price, type];
    window.close();
}

</script>
</head>
<body>

<img src="1.png" width="100px" height="100px" onClick='selectEdge("Square Edge 2mm ARRIS", 30.5, 1)'>
<img src="2.png" width="100px" height="100px" onClick='selectEdge("4 x 4 mm SINGLE BEVEL", 38.56, 1)'>
<img src="3.png" width="100px" height="100px" onClick='selectEdge("4 x 4 mm DOUBLE BEVEL", 46.49, 1)'>
<img src="4.png" width="100px" height="100px" onClick='selectEdge("V JOINT WITH SINGLE PENCIL", 38.56, 2)'>

</body>

I would add a JSFiddle but it opens a separate page so I can't ~ Any help appreciated!

Was it helpful?

Solution

When you close the popup, the data assigned by the popup is lost. (In IE)

I would suggest calling a function to the opener, from the popup, with the data as parameters. the function then sets (copies) the data to variables in the opener. So, this should work:
(Not yet tested)

Child window:

function selectEdge(name, price, type){
    opener.setEdge(name, price, type);
    window.close();
}

Parent Window:

function setEdge(name, price, type){
    edge = [name, price, type];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top