일반 document.domain (from mozilla.org)

황제낙엽 2013.03.13 15:56 조회 수 : 407

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



<한글 레퍼런스>
http://pakss328.blogspot.kr/2012/03/javascript.html
http://myheartu1.blog.me/140121043378
http://blog.naver.com/dlfdlwlfyd?Redirect=Log&logNo=30111900752
http://cafe.naver.com/webprogrammer2/43
http://support.microsoft.com/kb/813819/ko (IE6에서는 document.domain 가 지원되지 않습니다)

번호 제목 글쓴이 날짜 조회 수
125 characters from ISO 8859-1 황제낙엽 2020.11.10 28619
124 [ActiveX] CAB파일 수동 설치(레지스트리 등록) 방법 황제낙엽 2017.03.16 3162
123 네이버의 무료 나눔 글꼴 황제낙엽 2020.05.06 1110
122 <img> image 엘리먼트에서 이미지를 base64로 인코딩해서 사용하기 file 황제낙엽 2017.04.01 977
121 Document documentMode Property file 황제낙엽 2011.10.04 906
120 encoding, charset, code page, UTF-8, UNICODE ... file 황제낙엽 2013.08.07 731
119 pt, px, em, % 비교표 file 황제낙엽 2011.05.24 731
118 [MSDN] Document Object Model Prototypes (IE8) 황제낙엽 2011.03.24 716
117 User Agent 에 관련된 링크 황제낙엽 2017.11.20 595
116 Canvas 곡선 그리기 file 황제낙엽 2016.08.22 424
» document.domain (from mozilla.org) 황제낙엽 2013.03.13 407
114 ASCII Table and Description file 황제낙엽 2011.08.10 357
113 DIV태그로 테이블 만들기 황제낙엽 2005.12.24 300
112 Object의 주요 속성 황제낙엽 2011.02.14 278
111 모바일 브라우저에서 iframe 의 스크롤 문제 황제낙엽 2012.01.12 267
110 Canvas 도형의 클릭 이벤트 처리 황제낙엽 2016.08.22 263
109 Style cssText Property 황제낙엽 2012.09.13 257
108 스타일-보더 테스트 관련 레퍼런스 황제낙엽 2013.01.04 248
107 HTML5 강좌 2강 - HTML5 시맨틱웹을 위한 구성요소 file 황제낙엽 2016.12.03 246
106 로드밸런싱(L4)+아파치를 운영시 etag제거로 캐시 성능 최적화 file 황제낙엽 2018.03.28 226