Movatterモバイル変換


[0]ホーム

URL:


  1. Веб-технологии для разработчиков
  2. Интерфейсы веб API
  3. Document
  4. Document.domain

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

Document.domain

Устарело: Эта возможность была удалена из веб-стандартов. Хотя некоторые браузеры по-прежнему могут поддерживать её, она находится в процессе удаления. Не используйте её ни в старых, ни в новых проектах. Страницы или веб-приложения, использующие её, могут в любой момент сломаться.

Свойствоdomain уDocument интерфейса получает/устанавливает доменную часть источника происхождения (origin) текущего документа, используется вполитике ограничения домена (same origin policy).

Синтаксис

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

Значение

Доменная часть источника происхождения (origin) текущего документа.

Исключения

SecurityError

An attempt has been made to setdomain under one of the following conditions:

  • The document is inside a sandboxed<iframe>
  • The document has no browsing context
  • The document'seffective domain isnull
  • The given value is not equal to the document's effective domain (or it is not a registerable domain suffix of it)
  • Thedocument-domainFeature-Policy is enabled

Examples

Getting the domain

For the URIhttp://developer.mozilla.org/ru/docs/Web, this example setscurrentDomain to the string "developer.mozilla.org".

var currentDomain = document.domain;

Closing a window

If a document, such aswww.example.xxx/good.html, has the domain of"www.example.xxx", this example attempts to close the window.

var badDomain = "www.example.xxx";if (document.domain == badDomain) {  // Just an example: window.close() sometimes has no effect  window.close();}

Спецификации

Specification
HTML
# relaxing-the-same-origin-restriction

Совместимость с браузерами

Смотрите также

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp