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

I enable users to add tags via the jquery plugin. Upon the tag click event of a given tag, i parse out the tagLabel and extract a URL if present. Once I have the URL I open the external link. It is actually appending the link to my existing application for instance:

localhost/App1/www.cnn.com

it should be

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');
        });
    }
});

Answers:

Answer

You need to make sure the url starts with http or https

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.