Check If Link Contains External URL

    The following snippet will check if a clicked link contains a URL to an external web page and if so, open in a new browser window:
    [javascript]
    var root = location.protocol + ‘//’ + location.host;
    $(‘a’).not(‘:contains(root)’).click(function(){
    this.target = "_blank";
    });
    [/javascript]

    Leave a Reply