通过程序在窗口中打开一个外部URL,链接会附加到网站上

programatically opening an external URL in a window, link is appended to the site

本文关键字:链接 URL 外部 网站 一个 窗口 程序 过程      更新时间:2024-05-26

我允许用户通过jquery插件添加标签。在给定标签的标签点击事件后,我解析出标签标签并提取一个URL(如果存在)。一旦我有了URL,我就会打开外部链接。它实际上是将链接附加到我现有的应用程序中,例如:

localhost/App1/www.cnn.com

应该是

www.cnn.com

$('#myTags').tagit({
    select: true,
    sortable: true,
    editable: true,
    allowSpaces: true,
    triggerKeys: ['enter', 'comma', 'tab'],
    onTagClicked: function (evt, ui) {
        var tagy = ui.tagLabel;
        var result = URI.withinString(ui.tagLabel, function (url) {
            var URL = url;
            window.open(url, '_new');
        });
    }
});

您需要确保url以httphttps 开头