日期:2014-05-16  浏览次数:20296 次

IE中window.showModalDialog的问题
a通过window.showModalDialog弹出b,想在b中通过一个按钮改变b的地址(例如刷新自己),在firefox和Chrome中都可以,在IE中就会新弹出一个窗口,怎么让它不弹出呢?求高人指点。
附上代码:
a.html:
<html>
<body>
<input type="button" value="test" onclick="test()">
</body>
<script type="text/javascript">
function test()
{
window.showModalDialog("b.html","","");
}
</script>
</html>

b.html
<html>
<body>
<input type="button" value="go to Baidu" onclick="test()">
</body>
<script type="text/javascript">
function test()
{
document.location.href = document.location.href;
}
</script>
</html>

------解决方案--------------------

一楼啊 ··````
------解决方案--------------------
head里面添加
<base target="_self"> 

接分
------解决方案--------------------
引用:
自己顶一下。

ie中测试通过
b.html改成

<html>
<head>
   <base target="_self"> 
</head>

<body>
<a id="reload" href="b.html" style="display:none">reload...</a>
<input type="button" value="go to Baidu" onclick="test()"/>
</body>
<script type="text/javascript">
function test()
{
 var a = document.getElementById("reload");
 a.click();
}
</script>
</html>