0
$description = $this->t('A user-defined date format. See the <a href="http://php.net/manual/function.date.php" target="_blank">PHP </a> for available options.');    

This code does not open the link in a new tab, instead it opens on the same tab. is there a way I can fix this code? Or is there an alternate to target="_blank" or to open a URL in a new tab?

halfer
  • 19,824
  • 17
  • 99
  • 186
  • I believe that this can still be overriden by the user's local setting (especially in Chrome)...and, frankly, that should be the case. Related - http://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window-using-javascript?rq=1 – Paulie_D Feb 24 '16 at 12:47

3 Answers3

1

You can use jQuery :

add an ID to the ancher (here is id="myAnchor") :

$(document).on('click', 'a#myAnchor', function(e){ 
    e.preventDefault(); 
    var url = $(this).attr('href'); 
    window.open(url, '_blank');
});
SalmanShariati
  • 3,873
  • 4
  • 27
  • 46
0

use this for new tab in js

    <script> 
    window.open('http://testsite.com, "_blank");
    </script>
or
    <a href="javascript:void(0);" class="webMnu" onclick="window.open('http://testsite.com','plain');">Enroll</a>
Mohd Zubair Khan
  • 263
  • 2
  • 16
0

Check your page source. If in source you can also see target="_blank" then it means that action is overridden with JavaScript so you should fix JS.

MilanG
  • 6,994
  • 2
  • 35
  • 64