JavaScript document domain Property Tutorial

In this section, we will learn what the document domain property is and how to use it in JavaScript.

What is document domain Property in JavaScript?

The JavaScript document domain property is used to get the domain name of the server that the browser sent a request to get the currently loaded document.

document domain Property Syntax:

document.domain;

document domain Property Parameters

The property is read-only and so it doesn’t take any argument.

document domain Property Return Value

The return value of this method is the domain name of the server that the currently loaded document is taken from.

Note: if the domain cannot be identified, then the return value of the method becomes null.

Example: using document domain Property in JavaScript

See the Pen using document domain Property in JavaScript by Omid Dehghan (@odchan1) on CodePen.

Leave a Reply