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 247 views
1 answer 246 views
2 answers 430 views
1 answer 326 views
1 answer 383 views
2 answers 587 views
587 views asked Mar 31, 2018 by avibootz
1 answer 170 views
170 views asked Mar 10, 2017 by avibootz
...