We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Перевод не завершен. Пожалуйста, помогите перевести эту статью с английского.

Summary

Gets/sets the domain portion of the origin of the current document, as used by the same origin policy.

Syntax

var domainString = document.domain;
document.domain = string;

Example

// for document www.example.xxx/good.html,
// this script closes the window
var badDomain = "www.example.xxx";

if (document.domain == badDomain)
   window.close(); // Just an example - window.close() sometimes has no effect.
// For the URI http://developer.mozilla.org/en-US/docs/Web the
// following sets domain to the string "developer.mozilla.org"
var domain = document.domain;

Notes

Свойство возвращает null если домен документа не может быть идентифицирован. 

Mozilla позволит вам установить его в супердомен текущего значения, ограниченный его  базовым доменом. Например, на developer.mozilla.org возможно установить его как "mozilla.org" но не как  "mozilla.com" или "org".

 

Если это свойство успешно установленно, портовая часть источника так же уставнавливается на нуль.

Mozilla distinguishes a document.domain property that has never been set from one explicitly set to the same domain as the document's URL, even though the property returns the same value in both cases. One document is allowed to access another if they have both set document.domain to the same value, indicating their intent to cooperate, or neither has set document.domain and the domains in the URLs are the same (implementation). Were it not for this special policy, every site would be subject to XSS from its subdomains (for example, https://bugzilla.mozilla.org could be attacked by bug attachments on https://bug*.bugzilla.mozilla.org).

Specification

See also

Метки документа и участники

Внесли вклад в эту страницу: Horuslllll
Обновлялась последний раз: Horuslllll,