how close modal dialog from the first window

J

Jonan

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.

regards

Jonan
 
L

Lasse Reichstein Nielsen

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);

Is "erref" a global variable?
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.

You have a reference to the window that Jonan2.html is in (erref1). If
"erref" is a global variable of Jonan2.html, you can close it from
Jonan1.html as:
erref1.erref.close();
Then you can close Jonan2.html
erref1.close();

<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_3_12>
<URL:http://www.infimum.dk/HTML/JSwindows.html#ref_2_5>

/L
 
A

Alexander Ignatyev

Jonan said:
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:window});
dlgwin=null;
}
</script>
...
<button onclick=openDlg()>Open Dialog</button>

--------------dialogo.html -----------------
<script>
dialogArguments.opener.dlgwin=window;
</script>
 
J

Jonan

Alexander Ignatyev said:
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:window});
dlgwin=null;
}
</script>
..
<button onclick=openDlg()>Open Dialog</button>

--------------dialogo.html -----------------
<script>
dialogArguments.opener.dlgwin=window;
</script>


Hello Alexander,

thank you very much

Jonan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top