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

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -