最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Focus an Already Opened Tab in Safari Using window.open - Stack Overflow

programmeradmin12浏览0评论

I’m using window.open(url, "my_tab") to open a new tab in the browser. It works as expected in most browsers — it opens a new tab and reuses the same one if the button is clicked again. However, in Safari on mobile devices, it doesn’t automatically bring the already opened tab into focus. Is there a way to force Safari to focus the tab if it’s already open? I

const navigateToTheUrl = () => {
    if (windowObjectReference === null || windowObjectReference.closed) {
        windowObjectReference = window.open(testUrl.value, 'my_tab');
    } else {
      windowObjectReference.focus();
    }
};
发布评论

评论列表(0)

  1. 暂无评论