"Jonan" <jo********@yahoo.es> wrote :
Hi,
I use JavaScript
I have tree windows.
Jonan1.html has this code erref1=window.open("Jonan2.html",
"mypage",null); This opens Jonan2.html and it has this code
erref=window.showModalDialog("Dialogo.html",
null); This opens Dialogo.html
How can I do to close Jonan2.html and Dialogo.html from Jonan1.html
How can I get the Dialogo.html reference from Jonan1.html.
To do this, you can:
1) Pass johan2.html window reference to dialogo.html in arguments
2) In dialog script store dialog window reference to opening window
variable.
3) In jonan1.html close dialog window first, then close jonan2.html
Here's sample:
--------------johan1.html -----------------
<script>
var erref1=null;
function openIt() {
erref1=window.open("johan2.html", "mypage",null);
}
function closeIt() {
if (erref1 && !erref1.closed) {
if (erref1.dlgwin) erref1.dlgwin.close();
erref1.close();
}}
</script>
....
<button onclick=openIt() >Open johan2</button>
<button onclick=closeIt()>Close johan2</button>
....
--------------johan2.html -----------------
<script>
var dlgwin=null;
function openDlg() {
var retValue=showModalDialog("dialogo.html",{opener:wi ndow});
dlgwin=null;
}
</script>
...
<button onclick=openDlg()>Open Dialog</button>
--------------dialogo.html -----------------
<script>
dialogArguments.opener.dlgwin=window;
</script>
-----------------------------------------------
HTH