471,093 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,093 software developers and data experts.

how close modal dialog from the first window

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
Jul 20 '05 #1
3 20423
jo********@yahoo.es (Jonan) writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
"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
Jul 20 '05 #3
"Alexander Ignatyev" <al***@b52tech.com> wrote in message news:<bj***********@gavrilo.mtu.ru>...
"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

Hello Alexander,

thank you very much

Jonan
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Patrick Lim | last post: by
2 posts views Thread by Simon Storr | last post: by
8 posts views Thread by william | last post: by
2 posts views Thread by anil kumar via .NET 247 | last post: by
4 posts views Thread by Hitesh | last post: by
2 posts views Thread by sthrudel | last post: by
2 posts views Thread by =?Utf-8?B?TGVuaTIwMDA=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.