【转载】解决window.showModalDialog 模态窗口中location 打开新窗口问题

2023-05-10,,

来源: <http://bibipear.blog.sohu.com/143449988.html>

在我们的项目中,通常会用到showModalDialog 打开一个模态的子窗口,但是在这个子窗口中js方法里的document.location="" 通常会打开一个新的窗口,不论你的如何设置,问题的根源据我所以可能是js中遗留的问题,那么在js中document.location 唯独就是打开一个新的页面,但是同时<a href=""  的打开方式确可以在原窗口中打开。那么我们可以利用js创建一个模拟的点击链接,例如:

function go(url) 
{       
    var   a=document.createElement("a");   
    a.href=url;   
    document.body.appendChild(a);   
    a.click();

}

那么在使用document.location 时调用go(url),把你的请求做参数放入,无论是action,还是jsp都可以。

这样就就解决了模态中js调用location的问题了。

来自为知笔记(Wiz)

转载】解决window.showModalDialog 模态窗口中location 打开新窗口问题的相关教程结束。

《【转载】解决window.showModalDialog 模态窗口中location 打开新窗口问题.doc》

下载本文的Word格式文档,以方便收藏与打印。