则将窗口置于前面

则将窗口置于前面

本文介绍了如果已经在window.open中打开,则将窗口置于前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您打开如下窗口:

window.open ("url","winName","location=0,width=300,height=214");

如果 winName 已经打开,它只是更改窗口中的URL。这没关系,但如果那个窗口在当前窗口后面,大多数用户都不会意识到这一点,并认为它只是没有打开。

If winName is already open it just changes the URL in the window. This is ok but if that window is behind the current window most users won't realize this and think that it is just not opening.

有没有办法,如果窗口已经打开,它会把它带到前面吗?

Is there any way that if the window is already open, it brings it to the front?

推荐答案

更新:这还没有从Chrome(21岁以上)开始工作。解决方法是关闭/重新打开。

Update: This hasn't worked since Chrome (21+). The workaround is to close/reopen.

方法返回表示新窗口的对象。您只需即可:

The window.open() method returns an object that represents the new window. You just need to window.focus() it:

var w = window.open ("url","winName","location=0,width=300,height=214");
w.focus();

或者只是:

window.open("url","winName","location=0,width=300,height=214").focus();

这篇关于如果已经在window.open中打开,则将窗口置于前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 15:27