A页面使用showModalDialog 函数弹出B页面,在B页面中,使用了按钮单击事件修改页面路径如:
<input type="button" value="切换地址" onclick="window.location.herf='C.aspx'"/> 切换到C页面但是这样的话,会弹出一个新窗体显示C页面,而不是当前页面显示。
加了<base target="_self">也没用,这个只能对超链接有效。如何解决???
<input type="button" value="切换地址" onclick="window.location.herf='C.aspx'"/> 切换到C页面但是这样的话,会弹出一个新窗体显示C页面,而不是当前页面显示。
加了<base target="_self">也没用,这个只能对超链接有效。如何解决???
----------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function gotoModalDialog(url,w,h)
{
window.showModalDialog(url,"","dialogWidth="+w+"px; dialogHeight="+h+"px; resizable=yes;help=no;status=no;scroll=no");
}
</script>
</head>
<body>
<p></p>
<p>
<input type="button" value="模态窗体B" onclick="gotoModalDialog('modal.html','500','300')"/>
</p>
</body>
</html>B.html
----------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>B页面</title>
</head>
<body style="width:300px; height:300px">
<p>
<input type="button" value="关 闭" onclick="window.close()" />
<input type="button" value="更改URL" onclick="window.location='C.html'" /> <!--在新窗体打开了-->
<a href="c.html">连接</a><!--链接则有效:在本窗体打开-->
</p>
</body>
</html>C.html内容页<input type="button" value="更改URL" onclick="window.location='C.html'" />
通过js控制的代码都会弹出新窗体,动态页面后台写代码也是,如asp.net的后台
Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "<script>if(confirm('成功,即将关闭窗体')) window.close()");这句代码总是弹出新的窗体不会关闭页面。
<input type="button" value="切换地址" onclick="window.location.herf='C.aspx'"/>
改成
<a href="" target="_self"></a>
添加表单,form.action='url';form.submit() 代替 window.location='url'