How to open link in new tab on html?

后端 未结 10 2014
孤独总比滥情好
孤独总比滥情好 2020-11-22 11:57

I\'m working on an HTML project, and I can\'t find out how to open a link in a new tab without javascript.

I already know that

10条回答
  •  旧巷少年郎
    2020-11-22 12:29

    When to use target='_blank' :

    The HTML version (Some devices not support it):

    This link will open in new window/tab
    

    The JavaScript version for all Devices :

    The use of rel="external" is perfectly valid

    
    
    

    and for Jquery can try with the below one:

    $("#content a[href^='http://']").attr("target","_blank");
    

    If browser setting don't allow you to open in new windows :

    href = "google.com";
    onclick="window.open (this.href, ''); return false";
    

提交回复
热议问题