在链接上单击JS(anchrome.js)[保留]时,在新选项卡上打开链接]

问题描述 投票:-1回答:1

我正在使用js插件:https://github.com/alexcorvi/anchorme.js

此插件检测可链接文本,然后将其转换为链接。

已经过了几周,开发人员还没有回到我的面前,有人知道如何制作它,以便他们在新标签页中打开吗?

或您能否帮助提供替代解决方案?

感谢=)

javascript html jquery-plugins
1个回答
1
投票

从他们的官方文档中获取了以下摘录。

您可以通过以下方式在Anchrome库中使用'attributes'选项。

var string = "mylink.com";
var result = anchorme(string,{
    attributes:[
        {
            name:"target",
            value:"_blank"
        },
    ]
});
console.log(result) // <a href="http://mylink.com"  target="_blank" >mylink.com</a>

基本上,您需要添加属性以使其具有{ name:"target", value : "_blank"}

供进一步阅读:Usage

© www.soinside.com 2019 - 2024. All rights reserved.