Get Host name of the Website in JavaScript

Source code :

var x = location.hostname;
alert (x);

Output :

codecry.com

Algorithm :

  1. Get the host name using location.hostname
  2. Print the result

Output :


                

Comments :