模态窗口的妙用

来源:互联网 发布:软件破解版商店 编辑:程序博客网 时间:2024/05/17 01:55

模态窗口的妙用

 

 

      如果是做WebForm开发的人员一定是有这样的感触,要是WebForm中能够想WinForm下的子窗口就好了,这样的话如果想在一个

页面中做操做而又不用重新打开一个页面那么繁琐。其实很简单,用模态窗口就可以帮你轻松搞定。

 

      可能有用过模态窗口的同志通常就是直接  window.showModalDialog() 来使用,却苦于不知道操作后的状态而烦恼,

其实根本就不用烦恼,模态窗口是有返回值,你可以这样使用:

 

 例如:test.html

 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>     

      <title>模态窗口</title>

      <script language="javascript" type="text/javascript">

        function funReturnValue()
        {       
             var  strValue="Hello Word.";

             window.returnValue = strValue;
             window.close();
        }

        </script>

</head>

 

<body>

  <div>

 

       <input type="button" id="btnClose" value="关  闭"  onclick="javascript:funReturnValue();" />

</div>

</body>

 

 

index.html

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <base target="_self" />
       <script language="javascript" type="text/javascript">
        function ShowValue()
        {
            var Result  = window.showModalDialog("test.html","","dialogWidth=520px;dialogHeight=400px");

            alert(Result);
        }
    </script>
</head>

<body onload="javascript:ShowValue()">

</body>

     

原创粉丝点击