Open link in new window or focus to it if already open

前端 未结 6 2183
轮回少年
轮回少年 2020-12-03 02:37

I have a link which should open in a new tab, but if the tab is already open, just switch to it. I\'ve tried with javascript, wnd = window.open() and than wnd.focus(), that

6条回答
  •  渐次进展
    2020-12-03 03:26

    If the window is already opened and if you want to focus on that window you can use

    window.open('', 'NameOfTheOpenedWindow').focus();
    

提交回复
热议问题