sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | http://1 |
sitelink4 | http://ko |
extra_vars5 | https://developer.mozilla.org/ko/docs/DOM/document.domain |
extra_vars6 | sitelink1 |
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
1 2 3 4 5 6 | // 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. |
1 2 3 | // For the URI http://developer.mozilla.org/en/docs/DOM the // following sets domain to the string "developer.mozilla.org" var domain = document.domain; |
Notes
This property returns null
if the domain of the document cannot be identified.
In the DOM HTML specification, this property is listed as being read-only. However, Mozilla will let you set it to a superdomain of the current value, constrained by its base domain. For example, on developer.mozilla.org it is possible to set it to "mozilla.org" but not "mozilla.com" or "org". See the implementation (line number may rot).
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
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
68 | Canvas 도형의 클릭 이벤트 처리 | 황제낙엽 | 2016.08.22 | 351 |
67 | Canvas 이미지 추출 | 황제낙엽 | 2016.08.22 | 202 |
66 | Canvas 더블버퍼링 | 황제낙엽 | 2016.08.22 | 281 |
65 |
Canvas 비트맵 그리기
![]() | 황제낙엽 | 2016.08.22 | 124 |
64 |
Canvas 그라디언트 그리기
![]() | 황제낙엽 | 2016.08.22 | 141 |
63 |
Canvas 텍스트 그리기
![]() | 황제낙엽 | 2016.08.22 | 102 |
62 |
Canvas 곡선 그리기
![]() | 황제낙엽 | 2016.08.22 | 493 |
61 |
Canvas 다각형 그리기
![]() | 황제낙엽 | 2016.08.22 | 196 |
60 |
Canvas 사각형 그리기
![]() | 황제낙엽 | 2016.08.22 | 141 |
59 |
Canvas 시작하기
![]() | 황제낙엽 | 2016.08.22 | 100 |
58 | HTML5 개발을 도와주는 도구들 | 황제낙엽 | 2014.04.04 | 119 |
57 |
encoding, charset, code page, UTF-8, UNICODE ...
![]() | 황제낙엽 | 2013.08.07 | 838 |
» | document.domain (from mozilla.org) | 황제낙엽 | 2013.03.13 | 555 |
55 |
우리은행 웹 접근성 가이드
![]() | 황제낙엽 | 2013.03.08 | 158 |
54 | 모든 브라우저에서 동작하는 opacity 설정 코드 | 황제낙엽 | 2013.02.14 | 132 |
53 | DXImageTransform.Microsoft.AlphaImageLoader 와 file dialog | 황제낙엽 | 2013.01.28 | 244 |
52 | Gradient 와 Background-Image 동시 적용 방안 | 황제낙엽 | 2013.01.11 | 202 |
51 |
그라디언트와 다중 배경 (gradient)
![]() | 황제낙엽 | 2013.01.11 | 130 |
50 |
CSS Gradient Background Maker
![]() | 황제낙엽 | 2013.01.11 | 141 |
49 | Radius, Gradient, Padding | 황제낙엽 | 2013.01.11 | 142 |