对于像mozilla和IE 11这样的chrome和safari,top.location.href没有正确加载

时间:2015-07-21 15:47:42

标签: javascript java jsp google-chrome

问题出在chrome和safari浏览器中: - 我有一个main.jsp,因为我打开了一个弹出窗口。在弹出窗口中,我将top.location.href更改为其他jsp。在将新url分配给窗口页面之后,在我的代码结束之前没有加载新的url,因此窗口正在关闭。(仅在chrome中没有加载新的url但Firefox和IE11工作正常)

main.jsp代码 - >

<script type="text/javascript">
var url = 'popuppage.jsp';
 var newwindow = window.open(url,'name','height=400,width=750');
</script>

popuppage.jsp代码 - &gt;

<script type="text/javascript">
   top.location.href = "newpage.jsp";
    //have some logic for other usecases.
    window.close();
</script>

是否可以避免在top.location.href = URL?

之后执行代码

返回不会,因为它不在任何函数内。

是否可以在到达window.close()之前加载新网址?因为其他一些用例也需要window.close()。 要么 是否可以知道任何新的网址(将使用新网址加载的状态)分配给top.location.href

我已尝试使用以下方法reload(true)assign()replace(),top.location,但没有任何效果。

0 个答案:

没有答案
相关问题