模态对话框中进行提交而不新开窗口

在web页面中需要弹出一些模态窗口,对于如何应用大体做了一下总结。 

打开模态窗口 
var result = showModalDialog("b2.htm","dialogWidth:270px;dialogHeight:140px;status:'no'"); //显示dialog窗,result变量为此窗返回值数组 

从模态窗口返回值 
window.returnValue=”aaa” //返回aaa,可直接从表单里获取数据如document.all.textfield.value; 
window.close(); //关闭模态窗口 

向模态窗口传值 
传递 
var args = new array();args[0]=”a”; //第一个参数为”a” 
args[1]=”b”; //第二个参数为”b” 
url="a2.htm"; 
state="dialogWidth:200px;dialogHeight:100px;status:'no'"; 
var result = showModalDialog(url, args,state); 
窗口中接收 
v1=window.dialogArguments[0]; 
v2=window.dialogArguments[1]; 
模态窗口中的页面提交问题 
在模态窗口中,如有提交按钮,点击后会弹出新的页面。解决此问题有两种方法: 
1、在head中,添加注意:不要在form中再添加target="_self" 否则失效 
2、把弹出的窗口页面做成框架网页,去加载要展示的网页
如果你的浏览器是IE5.5+,可以在对话框中使用带name属性的iframe,提交时可以制定target为该iframe的name。对于IE4+,你可以用高度为0的frame来作:例子, 

  test6.htm 
  =================== 
 
    window.showModalDialog( "test7.htm ") 
   

  test7.htm 
  =================== 
  if(window.location.search)   alert(window.location.search) 
   
     
     
   

  test8.htm 
  =================== 
   
   
   
   
 
  if(window.location.search)   alert(window.location.search) 
   

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/787018/viewspace-712769/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/787018/viewspace-712769/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值