【问题标题】:Link open in new tab and focus on previous tab [duplicate]链接在新选项卡中打开并关注上一个选项卡[重复]
【发布时间】:2014-10-06 08:44:14
【问题描述】:

当链接在后台通过 jquery 在新选项卡中打开时,如何使焦点保持在同一个选项卡上?

【问题讨论】:

    标签: javascript jquery browser


    【解决方案1】:

    试试这个代码 -

       <p>Click the button to open a new window, and assure that the new window GETS focus (send the new window to the front).</p>
       <button onclick="myFunction()">Try it</button>
       <script>
          function myFunction() {
            var myWindow = window.open("", "", "width=200,height=100");
            myWindow.document.write("<p>A new window!</p>");
            myWindow.focus();
          }
       </script>
    

    【讨论】:

    • 我试过了,但它在新窗口中打开..
    • Rose:你到底想达到什么目标?
    • @Swetha:我希望在点击链接而不是新窗口时在后台打开一个选项卡..
    猜你喜欢
    • 2017-01-05
    • 2012-04-25
    • 2012-05-03
    • 2013-02-17
    • 2017-04-08
    • 1970-01-01
    • 1970-01-01
    • 2016-03-27
    • 2013-03-11
    相关资源
    最近更新 更多