在主窗口调用window.showModalDialog,弹出一个子窗口。
现在希望弹出子窗口以后,主窗口能够最小化,然后关闭子窗口以后,主窗口能够自动复原成最大。
请问一下用js怎么实现?
对js不是太熟悉,希望能给个例子。

解决方案 »

  1.   

    写了个简单实现,楼主参考下
    b.html父窗口<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>父窗口</title>

    </head><body>
    <input type="button" onclick="openWindow()" value="click">
    </body>
    <script language="javascript">
    function   max_window(){
    var   window_width=screen.availWidth
    var   window_height=screen.availHeight
    window.resizeTo(window_width,window_height)
    window.moveTo(0,0) 
    }function min_window(){
    window.resizeTo(0,0)
    window.moveTo(1600,1600) 
    }function openWindow(){
    window.showModalDialog("b1.html", window,"dialogHeight:200px;dialogWidth:300px");
    }</script>
    </html>b1.html子窗口<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>子窗口</title>

    </head><body>
    </body>
    <script language="javascript">
    var parentWin=window.dialogArguments; 
      parentWin.min_window(parentWin);
      window.onbeforeunload = function(){
      parentWin.max_window();
    }
    </script>
    </html>
      

  2.   

    感谢ls。
    不过模态窗口的情况下,大小最小只能到100,不能缩到0,另外,也不能移出桌面以外。
    有没有什么办法可以回避一下呢?
    我现在的问题是主窗口是沾满屏幕的,弹出子窗口以后就不能把子窗口的内容和其他程序的内容进行比较了。
    (ALT+TAB切换起来,感觉比较不是太方便。