Get base url using <a> element - Node.js DOM

Node.js examples for DOM:Element

Description

Get base url using <a> element

Demo Code

function getBaseURL (url) {
    var a = document.createElement('a');
    a.href = url;/*from ww  w. j  a  v a 2  s  .c o m*/
    return a.protocol + "//" + a.hostname + ":" + a.port;
}

Related Tutorials