Javascript 通过编程在窗口中打开外部URL,链接会附加到站点
我允许用户通过jquery插件添加标签。在给定标记的tag click事件发生后,我解析出tagLabel并提取URL(如果存在)。一旦我有了URL,我就会打开外部链接。它实际上是将链接附加到我现有的应用程序中,例如: localhost/App1/www.cnn.comJavascript 通过编程在窗口中打开外部URL,链接会附加到站点,javascript,Javascript,我允许用户通过jquery插件添加标签。在给定标记的tag click事件发生后,我解析出tagLabel并提取URL(如果存在)。一旦我有了URL,我就会打开外部链接。它实际上是将链接附加到我现有的应用程序中,例如: localhost/App1/www.cnn.com $('#myTags').tagit({ select: true, sortable: true, editable: true, allowSpaces: true, trigger
$('#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');
});
}
});
应该是
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以
http
或https
开头。您需要确保url以http
或https
开头