How to get URL host name (hostname) in JavaScript

1 Answer

0 votes
var hn = window.location.hostname;
alert(hn);

/*

run:
  
localhost
  
*/'

 



answered Jun 21, 2018 by avibootz
edited Jun 21, 2018 by avibootz

Related questions

1 answer 239 views
1 answer 241 views
2 answers 424 views
1 answer 321 views
1 answer 380 views
2 answers 584 views
584 views asked Mar 31, 2018 by avibootz
1 answer 166 views
166 views asked Mar 10, 2017 by avibootz
...