如何从其他窗口代码的其他窗口的顶部将已经存在的打开窗口置于前面? [英] How do I bring an already existing open window to the front on top of other windows from another windows code?

查看:137
本文介绍了如何从其他窗口代码的其他窗口的顶部将已经存在的打开窗口置于前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



基本上,我有 window1 。点击一个按钮链接打开 window2 。点击 window2 中的一个按钮打开 window3 ,点击 window3中的按钮应该把 window2 带回到 window2 顶部的屏幕前面。



我不确定这是如何完成的,但是我已经使用过并使用了focus(),opener和其他各种方法,我似乎无法使其正常工作。

解决方案

更新:自Chrome(21+)以来,此功能无法使用。解决方法是关闭/重新打开。

  opener.focus()
pre>

确实有效。如果它不适合你,我们将需要一个测试用例。



有些事情可能会导致问题:在事件处理程序中调用它,该事件处理程序在之前触发 按钮的窗口由于点击而获得焦点(但我认为通常情况并非如此);在浏览器中运行它,而不是浏览器标签中的弹出窗口。



(我同意Max的评论,通常最好避免使用跨窗口脚本的弹出窗口。 )

The question was fairly descriptive but I'll describe it further.

Basically, I have window1. Clicking a button link opens window2. Clicking a button in window2 opens window3, clicking a button in window3 should bring window2 back to the front of the screen on top of window2.

I'm not sure how this is exactly done, however I have used and played around with focus(), opener and other various methods and I cannot seem to get it to work properly.

解决方案

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

opener.focus()

does work. If it doesn't for you, we'll need a test case.

Some things that might cause problems: calling it in an event handler that fires before the button's window gets focus due to the click (but I don't think that'd usually be the case); running it on a browser that stuffs pop-ups into browser tabs instead.

(I agree with Max's comment. Pop-ups with cross-window scripting are generally best avoided.)

这篇关于如何从其他窗口代码的其他窗口的顶部将已经存在的打开窗口置于前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆