How to display the domain of the server that loaded a document in JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

Javascript has provided document object to get any detail regarding a document. It has provided document.domain to get the domain of the server in which document loaded.


In the following example, the document is loaded in "tutorialspoint" server. Therefore the domain which we will get is "". Document.domain is an inbuilt function used to get the domain of the server in which the document is loaded. When this method is used in the "tutorialspoint" server, the domain with respect to the "tutorialspoint" is loaded as shown in the output.

 Live Demo

<p id="domain"></p>
   document.getElementById("domain").innerHTML =
   'The domain name is :'+" "+document.domain;


The domain name is
Published on 26-Jul-2019 16:19:21