How do you close a modal window from it with a parent?

Is it possible to close a modal window from it with the parent? It’s hard to even try to do it. Basically, I open a modeless window. From this modeless window the user can open the modal window several times. Now suppose I close a modeless window ... I would also like to close the modal subtitle. How can I do that?

In general, in general, I need to find a way to close the modal window from it with the parent.

Thanks Grae

Here is some code that will give you a sample.

home page


    <html>
   <head>
     <script>
        window.childWindow;
        function openNonModal()
        {
           window.childWindow = window.open("nonmodal.html","_blank", "dialogWidth=500px;dialogHeight=294px;scroll=no;status=no;caption=no;titlebar=no;menubar=no;toolbar=no;help=no");
           setTimeout("closeChildWindow()",5000);
        }

    function closeChildWindow()
    {
       window.childWindow.closeChildWindow();
       window.childWindow.close();
    }
 <script>

</a> < input type="button" value = "openNonModal" onclick = "openNonModal(); return false;" /"> </HTML>

code>

A modeless window that opens a modal window.


    <html>
   <head>
     <script>
        function openModal()
        {
           var retVal = window.showModalDialog("modal.html","_blank", "dialogWidth=500px;dialogHeight=294px;scroll=no;status=no;caption=no;titlebar=no;menubar=no;toolbar=no;help=no");
        }
        function closeChildWindow()
        {
           alert("should close child window");

    }
 </script>

</a> < input type="button" value = "openModal" onclick = "openModal(); return false;" /"> </HTML>

code>

A modal window is just text.


    <html>
   Just a sample.
</html>
+3
source share
1 answer

, , - .

:

setTimeout('alert(1);', 1000);
setTimeout('alert(2);', 2000);
setTimeout('window.showModalDialog(...);', 3000);
setTimeout('alert(3);', 4000);

alert(1) .

alert(2) , alert(1).

3- , , alert(3) 4- .

alert(3) , , , alert(3) .

: , : - (

+2

Source: https://habr.com/ru/post/1763113/


All Articles