yangbo1992 发表于 2013-1-29 08:38:33

关于window.showModalDialog()返回值的学习

先介绍一个showModaldialog的基本用法 使用方法:vReturnValue = window.showModalDialog(URL [, Arguments] [,Features])参数说明:URL--必选参数,类型:字符串。用来指定对话框要显示的文档的URL。Arguments--可选参数,类型:变体。用来向对话框传递参数。传递的参数类型不限,包括数组等。对话框通过window.dialogArguments来取得传递进来的参数。Features--可选参数,类型:字符串。用来描述对话框的外观等信息,可以使用以下的一个或几个,用分号“;”隔开。1.dialogHeight :对话框高度.2.dialogWidth: 对话框宽度。3.dialogLeft: 离屏幕左的距离。4.dialogTop: 离屏幕上的距离。5.center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。6.help: {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes。7.resizable: {yes | no | 1 | 0 } :是否可被改变大小。默认no。8.status: {yes | no | 1 | 0 } :是否显示状态栏。默认为yes[ Modeless]或no。9.scroll:{ yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。下面几个属性是用在HTA中的,在一般的网页中一般不使用。10.dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印预览时对话框是否隐藏。默认为no。11.edge:{ sunken | raised }:指明对话框的边框样式。默认为raised。12.unadorned:{ yes | no | 1 | 0 | on | off }:默认为no。 下面主要就针对返回值的两个例子 view plaincopyprint?    <html xmlns="http://www.w3.org/1999/xhtml">      <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />      <title>无标题文档</title>      <mce:script type="text/javascript"><!--      function oper()      {          var address=window.showModalDialog("return.html","aaaa","dialogWidth=400px;dialogHeight=200px");          document.myform.txtReturnValue.value=address;          }      // --></mce:script>      </head>      <body>      <form name="myform" method="post">      <div>      <div><input type="button" name="xxx" value="返回值"/><input type="text" name="txtReturnValue" /></div>      </div>      </form>      </body>      </html>    view plaincopyprint?    <html>      <head>      <Title></Title>      <mce:script type="text/javascript"><!--      function returntest()      {          window.returnValue="我是返回值";          window.close();                  }      // --></mce:script>      </head>      <body>      <form>      <input type="button"value="返回值"/>      </form>      <body>      <html>//---------------------------------------------------------------------------------------------------------------------- view plaincopyprint?    <html xmlns="http://www.w3.org/1999/xhtml" >       <head id="Head1" runat="server">         <title>无标题页 </title>         <mce:script type="text/javascript"><!--          function btnClick()          {            var ret = window.showModalDialog("b.aspx");               if (ret != null)               {               window.document.getElementById("TextBox1").value = ret;               window.document.getElementById("TextBox2").value = ret;               }               return false;          }                // --></mce:script>      </head>       <body>         <form id="form1" runat="server">         <div>               <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return btnClick();" />          </div>         </form>       </body>       </html>    view plaincopyprint?    <html xmlns="http://www.w3.org/1999/xhtml" >      <head id="Head1" runat="server">          <title>无标题页</title>          <mce:script type="text/javascript"><!--            function btnClick()            {                  var ret = new Array(2);                     ret = "aa";                     ret = "bb";                     window.returnValue = ret;                     window.close();                  return false;            }                // --></mce:script>      </head>      <body>          <form id="form1" runat="server">          <div>            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return btnClick()" />          </div>          </form>      </body>      </html>
页: [1]
查看完整版本: 关于window.showModalDialog()返回值的学习