How do I bring an already existing open window to the front on top of other windows from another windows code?

前端 未结 2 1685
春和景丽
春和景丽 2021-01-14 10:27

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

Basically, I have window1. Clicking a button link opens window2. Clickin

2条回答
  •  无人共我
    2021-01-14 10:58

    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.)

提交回复
热议问题