일반 document.domain (from mozilla.org)

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

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 가 지원되지 않습니다)

번호 제목 글쓴이 날짜 조회 수
128 characters from ISO 8859-1 황제낙엽 2020.11.10 32379
127 [ActiveX] CAB파일 수동 설치(레지스트리 등록) 방법 황제낙엽 2017.03.16 3545
126 What’s wrong with extending the DOM 황제낙엽 2011.03.28 2953
125 iframe 다루기 황제낙엽 2017.02.27 1906
124 네이버의 무료 나눔 글꼴 황제낙엽 2020.05.06 1313
123 <img> image 엘리먼트에서 이미지를 base64로 인코딩해서 사용하기 file 황제낙엽 2017.04.01 1201
122 Document documentMode Property file 황제낙엽 2011.10.04 1043
121 User Agent 에 관련된 링크 황제낙엽 2017.11.20 967
120 encoding, charset, code page, UTF-8, UNICODE ... file 황제낙엽 2013.08.07 946
119 [MSDN] Document Object Model Prototypes (IE8) 황제낙엽 2011.03.24 906
118 ASCII Table and Description file 황제낙엽 2011.08.10 901
117 pt, px, em, % 비교표 file 황제낙엽 2011.05.24 847
» document.domain (from mozilla.org) 황제낙엽 2013.03.13 681
115 Canvas 곡선 그리기 file 황제낙엽 2016.08.22 584
114 [보안] 혼합 콘텐츠(Mixed Content) 방지 황제낙엽 2017.04.13 534
113 Flash OBJECT and EMBED tag attributes 황제낙엽 2011.03.02 457
112 로드밸런싱(L4)+아파치를 운영시 etag제거로 캐시 성능 최적화 file 황제낙엽 2018.03.28 454
111 Canvas 도형의 클릭 이벤트 처리 황제낙엽 2016.08.22 452
110 스타일-보더 테스트 관련 레퍼런스 황제낙엽 2013.01.04 433
109 모바일 브라우저에서 iframe 의 스크롤 문제 황제낙엽 2012.01.12 418