目标=" _blank"没有打开新标签

时间:2016-02-24 11:43:45

标签: javascript php html css drupal

$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.');    

此代码不会在新选项卡中打开链接,而是在同一选项卡上打开。有没有办法可以修复这段代码?或者是否有target="_blank"的替代或在新标签中打开网址?

3 个答案:

答案 0 :(得分:1)

你可以使用jQuery:

为ancher添加一个ID(这里是id =“myAnchor”):

$(document).on('click', 'a#myAnchor', function(e){ 
    e.preventDefault(); 
    var url = $(this).attr('href'); 
    window.open(url, '_blank');
});

答案 1 :(得分:0)

将其用于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>

答案 2 :(得分:0)

检查您的页面来源。如果在源代码中您还可以看到target="_blank",那么这意味着使用JavaScript覆盖了操作,因此您应该修复JS。