用showModalDialog显示模态窗口

这项方法开启一个对话窗口,在这个对话窗口关闭前,其他窗口都无法使用。

 

语法:

      window.showModalDialog(arg1,arg2,arg3)

     arg1:要打开的文件url。

     arg2:增加属性的对象。这个程序窗口会使用dialogArgument属性取得此对象。

     arg3:以分号分隔的样式列表。

      在模态窗口中使用window.dialogArguments可获得打开此窗口的引用.

例:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>showModalDialog</title>
    <script type="text/javascript">
        function openWindow()
        {
            var myArguments = new Object();
            myArguments.参数1 = docunet.all.myColor.value;
            window.showModalDialg("dw.htm",myArguments,'');
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <select id="myColor">
            <option value ="red">Red</option>
            <option value = "green">Green</option>
            <option value = "yellow">Yellow</option>
        </select>
        <button onclick = "openWindow()">showModalDialog</button>
    </div>
    </form>
</body>

</html>

 

dw.htm:

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>dw.htm</title>
    <script type="text/javascript">
        function loadForm()
        {
            document.all.div1.style.backgroundColor = window.dialogArguemnts.参数1;
        }
    </script>
</head>
<body onload = "loadForm()">
    <form id="form1" runat="server">
    <div>
        <div id = "div1" style="width:100px;height:100px;" />
        <button onclick = "window.close();">Close</button>
    </div>
    </form>
</body>
</html>

 

 

你可能感兴趣的:(showModalDialog)