模态窗口中的页面如有提交按钮,点击后会弹出新的页面。解决此问题有两方法:1、在head中,添加;2、把弹出的窗口页面做成框架网页,去加载要展示的网页;
模态窗口中的页面如有提交按钮,点击后会弹出新的页面。
解决此问题有两方法:
1、在head中,添加<base target="_self">;
2、把弹出的窗口页面做成框架网页,去加载要展示的网页;
下面就第一种解决方法给出自己写的一个实例
(1)新建一个htm文件
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
SelectFilterCondition.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>请选择…</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<base target="_self" />
<script language="javascript">
function Load(){
window.Code.location.href = 'SelectFilterCondition.aspx'+window.location.search;
}
</script>
</head>
<body topmargin=0 bottommargin=0 leftmargin=0 rightmargin=0 onload="Load()">
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<td>
<iframe id=Code name=Code frameborder=0 height=100% width=100% scrolling="no"></iframe>
</td>
</tr>
</table>
</body>
</html>
(2)调用以下JS脚本
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
JSCode
function DoSelect()
{
var ht = document.getElementById("hidText");
var hd = document.getElementById("HidTxtID").value;
var cbs = document.getElementsByName("Sel");
ht.value ="";
for(var i=0;i<cbs.length;i++)
{
if(cbs[i].checked==true)
{
ht.value +=cbs[i].value+",";
}
}
ht.value=(ht.value).substr(0,(ht.value).length-1);
window.returnValue = ht.value;
window.close();
}
function OpenTextWin(ID,Filed,TxtID,SearchType)
{
var url="SelectFilterCondition.htm?ID="+ID+"&Filed="+Filed+"&TxtID="+TxtID+"&SearchType="+SearchType;
var rv = ShowModalDialog(url, 650, 550) ;
if( rv!=null && rv.length > 0)
{
if( TxtID != null )
{
TxtID.value = rv ;//显示值
}
}
}
(3)在使用页面中根据参数调用JSCode
例如在使用页面中添加代码:
<INPUT name='FC03_AB0111' size="12" type="text" id ='t4'/>
<input type='button' name='Submit' value='…' onclick="OpenTextWin('308236ED-4AA3-4FC4-8CE6-7ABEF9403A9F','FC03_AB0111',$('t4'),'search')" />
在弹出页面中添加代码:
<INPUT onclick="DoSelect()" type="button" value=" 确 定 ">
完成以上步骤以后即解决了模态窗口提交表单时弹出新窗口的问题,一个实用的带查询的模态窗口将展现在你面前!
(4)贴出实例的一张图片出来让大家看看
![](https://images.cnblogs.com/cnblogs_com/dreamof/showModel.jpg)
关于模态窗口(showModalDialog)的深入学习可参考:http://www.cnblogs.com/xiaotao823/archive/2009/02/05/1384836.html