D
Dave
I see this problem in IE but not Firefox.
I have a page that opens a second page as a dialog box. If the Dialog
is relaunched from a second instance on the page the Dialog window is
reused, the controls are reinitialized but window.opener still refers to
the original opener. I have simplified code than demonstrated the
problem.
This is the code for the base window which launches the dialog called
Base.html:
<html><head><title>Base</title>
<script language="javascript">
function launch(){
var w = window.open(
"dialog.html",
"Dialog",
"width=400,height=389,scrollbars=no,menubar=no");
w.focus();
}
function callBack(){
alert("callBack : "+document.getElementById("name").value);
}
</script>
</head>
<body>
<input type="text" id="name"/n>
<input type="button" onClick="launch()" value="Launch" />
</body>
</html>
You see it has a text box, a button and a couple of javascript
functions. When you click the button the Dialog window is launched.
The callBack function is called by the dialog window and throws up an
alert with the contents of the text box. If you type different text
into the text box of both you can then tell which one threw up the alert
box.
Here's the code for Dialog.html:
<html><head><title>Dialog</title>
<script language="javascript">
function linkBack(){
window.opener.callBack();
}
</script>
</head>
<body>
<p>Dialog</p>
<input type="button" onClick="linkBack()" value="Link Back"/>
</body>
</html>
Here we have a button and a javascript function that's called when the
button is clicked. The Javascript function calls through window.opener
to teh callBack function in the opener.
In IE, launch 2 instances of Base.html. In the text box of one of them
type X and click "launch". Then go to the 2nd instance, type Y and
click "Launch". There will only be one instance of the Dialog but click
the "Link Back" button in the Dialog and "callBack : X" will be
displayed.
You could throw some javascript in the onload method of the body tag is
you want to convince yourselfe that the Dialog is actually being
reloaded.
Why isn't the window.opener property updated?
I have a page that opens a second page as a dialog box. If the Dialog
is relaunched from a second instance on the page the Dialog window is
reused, the controls are reinitialized but window.opener still refers to
the original opener. I have simplified code than demonstrated the
problem.
This is the code for the base window which launches the dialog called
Base.html:
<html><head><title>Base</title>
<script language="javascript">
function launch(){
var w = window.open(
"dialog.html",
"Dialog",
"width=400,height=389,scrollbars=no,menubar=no");
w.focus();
}
function callBack(){
alert("callBack : "+document.getElementById("name").value);
}
</script>
</head>
<body>
<input type="text" id="name"/n>
<input type="button" onClick="launch()" value="Launch" />
</body>
</html>
You see it has a text box, a button and a couple of javascript
functions. When you click the button the Dialog window is launched.
The callBack function is called by the dialog window and throws up an
alert with the contents of the text box. If you type different text
into the text box of both you can then tell which one threw up the alert
box.
Here's the code for Dialog.html:
<html><head><title>Dialog</title>
<script language="javascript">
function linkBack(){
window.opener.callBack();
}
</script>
</head>
<body>
<p>Dialog</p>
<input type="button" onClick="linkBack()" value="Link Back"/>
</body>
</html>
Here we have a button and a javascript function that's called when the
button is clicked. The Javascript function calls through window.opener
to teh callBack function in the opener.
In IE, launch 2 instances of Base.html. In the text box of one of them
type X and click "launch". Then go to the 2nd instance, type Y and
click "Launch". There will only be one instance of the Dialog but click
the "Link Back" button in the Dialog and "callBack : X" will be
displayed.
You could throw some javascript in the onload method of the body tag is
you want to convince yourselfe that the Dialog is actually being
reloaded.
Why isn't the window.opener property updated?