HTML DOM Document domain attribute

Definition and usage

domain Property returns the domain of the server (from where the document is loaded).

If the document is created in memory, then domain Property returns null.

See also:

Window Location Object

Window History Object

Window Navigator Object

Example

Returns the domain of the server loading this document:

let myDomain = document.domain;

Try it yourself

Syntax

document.domain

Return value

Type Description
String The domain of the server (where the file is loaded from).
null If the domain cannot be recognized.

Browser support

document.domain It is a DOM Level 2 (2001) feature.

All browsers support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support 9-11 Support Support Support Support