模态对话框中进行提交而不新开窗口
上一篇 /
下一篇 2011-12-05 23:56:49
/ 个人分类:java
在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中,添加<base target="_self">注意:不要在form中再添加target="_self" 否则失效 2、把弹出的窗口页面做成框架网页,去加载要展示的网页如果你的浏览器是IE5.5+,可以在对话框中使用带name属性的iframe,提交时可以制定target为该iframe的name。对于IE4+,你可以用高度为0的frame来作:例子,
test6.htm
===================
<script>
window.showModalDialog( "test7.htm ")
</script>
test7.htm
===================
if(window.location.search) alert(window.location.search)
<frameset rows= "0,* ">
<frame. src= "about:blank ">
<frame. src= "test8.htm ">
</frameset>
test8.htm
===================
<form. target= "_self " method= "get ">
<input name=txt value= "test ">
<input type=submit>
</form>
<script>
if(window.location.search) alert(window.location.search)
</script>
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: