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

8 篇文章 0 订阅

 先介绍一个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 } [IE5+]:是否可被改变大小。默认no。
8.status: {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[ Modeless]或no[Modal]。
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。

 

下面主要就针对返回值的两个例子

[xhtml]  view plain  copy
 print ?
  1. <html xmlns="http://www.w3.org/1999/xhtml">  
  2. <head>  
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  4. <title>无标题文档</title>  
  5. <mce:script type="text/<a href="http://lib.csdn.net/base/18" class='replace_word' title="JavaScript知识库" target='_blank' style='color:#df3434; font-weight:bold;'>JavaScript</a>"><!--  
  6. function oper()  
  7. {  
  8.     var address=window.showModalDialog("return.html","aaaa","dialogWidth=400px;dialogHeight=200px");  
  9.     document.myform.txtReturnValue.value=address;  
  10.     }  
  11. // --></mce:script>  
  12. </head>  
  13. <body>  
  14. <form name="myform" method="post">  
  15. <div>  
  16. <div><input type="button" name="xxx" value="返回值" onclick="oper()" /><input type="text" name="txtReturnValue" /></div>  
  17. </div>  
  18. </form>  
  19. </body>  
  20. </html>  

 

[xhtml]  view plain  copy
 print ?
  1. <html>  
  2. <head>  
  3. <Title></Title>  
  4. <mce:script type="text/javascript"><!--  
  5. function returntest()  
  6. {  
  7.     window.returnValue="我是返回值";  
  8.     window.close();  
  9.       
  10.     }  
  11. // --></mce:script>  
  12. </head>  
  13. <body>  
  14. <form>  
  15. <input type="button" onClick="returntest()" value="返回值"/>  
  16. </form>  
  17. <body>  
  18. <html>  

//----------------------------------------------------------------------------------------------------------------------

[xhtml]  view plain  copy
 print ?
  1. <html xmlns="http://www.w3.org/1999/xhtml" >   
  2. <head id="Head1" runat="server">   
  3.     <title>无标题页 </title>   
  4.     <mce:script type="text/javascript"><!--  
  5.     function btnClick()  
  6.     {  
  7.         var ret = window.showModalDialog("b.aspx");   
  8.         if (ret != null)   
  9.         {   
  10.           window.document.getElementById("TextBox1").value = ret[0];   
  11.           window.document.getElementById("TextBox2").value = ret[1];   
  12.         }   
  13.         return false;  
  14.     }  
  15.       
  16. // --></mce:script>  
  17. </head>   
  18. <body>   
  19.     <form id="form1" runat="server">   
  20.     <div>   
  21.         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
  22.         <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>  
  23.         <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return btnClick();" />  
  24.     </div>   
  25.     </form>   
  26. </body>   
  27. </html>   

[xhtml]  view plain  copy
 print ?
  1. <html xmlns="http://www.w3.org/1999/xhtml" >  
  2. <head id="Head1" runat="server">  
  3.     <title>无标题页</title>  
  4.     <mce:script type="text/javascript"><!--  
  5.         function btnClick()  
  6.         {  
  7.               var ret = new Array(2);   
  8.               ret[0] = "aa";   
  9.               ret[1] = "bb";   
  10.               window.returnValue = ret;   
  11.               window.close();  
  12.               return false;  
  13.         }  
  14.       
  15. // --></mce:script>  
  16. </head>  
  17. <body>  
  18.     <form id="form1" runat="server">  
  19.     <div>  
  20.         <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return btnClick()" />  
  21.     </div>  
  22.     </form>  
  23. </body>  
  24. </html>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值