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 Objekt

Window History Objekt

Window Navigator Objekt

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 feature of DOM Level 2 (2001).

All web browsers support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Stöd 9-11 Stöd Stöd Stöd Stöd