How can I open a link in new tab (and not new window)?

This question already has an answer here:

  • How to open link in new tab on html? 11 answers

  • CSS3 supports "open in new tab", by the property target-new

    target-new: window | tab | none;
    

    Update [2016]: this method never made it into the CSS3 spec, as one of the comments indicates. This shouldn't be used. However, it can be seen that most modern browsers open target='_blank' links in a new tab anyway, unless one attempts to resize the new tab immediately thereafter. However, there does not appear to be a mechanism to force this behavior in the specifications.


    [2011] For a method of forcing opening in a new tab that is well supported, try the following:

    <a href="some url" target="_newtab">content of the anchor</a>
    

    Else, use this method to resize window immediately, to ensure that popup blockers do not kill your popup


    Other than the CSS3 target-new option @anirudh4444 mentioned, you can't and mostly importantly probably shouldn't. You are trying to control the user's experience, when this should most likely be left up to the user.


    You can use any of the following, I tested them all in 6 different browsers. (Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, Opera, K-meleon* and Seamonkey.)

  • <a href="blaah" target="_blank">Blaah</a>
  • <a href="blaah" target="_tab">Blaah</a>
  • <a href="blaah" target="_new">Blaah</a>
  • They all work the exact same, and the choice is completely up to preference.

    *K-meleon, for some reason just opened up the page I was on when I clicked the link.

    链接地址: http://www.djcxy.com/p/36606.html

    上一篇: 在Notepad ++中格式化/缩进XML / HTML

    下一篇: 我如何在新标签页中打开链接(而不是新窗口)?