javascript test if URL relative or absolute and not mailto:
<p>I have tables with buttons/links/email with mailto: and have written a default double click function which on double click of the row will direct the user to the last link in the table. </p>

<p>99% of tables will have the Edit button in the last column.</p>

<pre><code>$('table:not(.noDoubleClick) tr td').dblclick(function() {
    var linkEl = $(this).parents('tr').find('td:last-child a');

    if(!linkEl.length){
        return false;
    }

    if (linkEl.attr('href') &amp;&amp; linkEl.attr('onclick') === undefined &amp;&amp; !linkEl.hasClass("popme")) {
        document.location = linkEl.attr('href');
    } else {
        linkEl.click();
    }
});
</code></pre>

<p>This works fine until I have a rare table where the last column is a email address with a mailto. </p>

<p><strong>Q:</strong> How could I check if the href is relative/absolute link only. So that this would exclude mailto: and any other links which are not standard URLs.</p>

<p>I know I could do something like this: <code>linkEl.attr('href').substring(0, 7) == "mailto:"</code> to test specifically for mailto but is there a better way of doing this without a load of IFs testing for the different protocols to be excluded. </p>

<p>Update with working solution from @epascarello:</p>

<pre><code>$('table:not(.noDoubleClick) tr td').dblclick(function(e) {
    var linkEl = $(this).parents('tr').find('td:last-child a');
    var linkElHref = linkEl.attr('href');

    // Check if has href and http protocol
    if(!linkElHref.length || this.protocol.indexOf("http") !== 0){
        e.preventDefault();
        return false;
    }

    if (linkElHref &amp;&amp; linkEl.attr('onclick') === undefined &amp;&amp; !linkEl.hasClass("popme")) {
        document.location = linkElHref;
    } else {
        linkEl.click();
    }
});
</code></pre>
