dom - parse url - javascript -


i try parse url in angular way:

var l = document.createelement("a"); l.href='www.example.com'; console.log(l.hostname); // -> '127.0.0.1' 

but log gives me localhost. ideas why that's case or better ways how it?

you should use absolute url protocol:

l.href='http://www.example.com'; 

Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -