JS篇 同源策略、CORS、XSS、SessionCookie
同源策略: 如何引用: (iFrame指的是iframe DOM节点) 1. 引用iframe的window对象:iFrame.contentWindow 2. 引用iframe的document对象:iFrame.contentDocument,或者:iFrame.contentWindow.document 示例: 两个页面,前者页面中嵌入iframe,src指向后者: 1. test.nuomi.com/link1.vm 2. nuomi.com/link2.vm; 同源要求:Protocols, domains, and ports均相同 子域名不同的两个站:test.nuomi.com, nuomi.com,如果要通信, 都 必须设置为统一的域名:document.domain=nuomi.com; 即使其中一个已经是域名:nuomi.com,仍然需要 明确调用 :document.domain=nuomi.com; document.domain设值: 1. 只能是当前域名的suffix,否则报错:Uncaught SecurityError: Failed to set the 'domain' property on 'Document': 'test' is not a suffix of 'test.nuomi.com'. 2. 设值为com也会报错:'com'