兴盛某些界限要求的情况下cosplay 足交,页面是不错修改它的源。剧本不错将 document.domain 的值开荒为其现时域或其现时域的父域。要是将其开荒为其现时域的父域,则这个较短的父域将用于后续源检讨。
在线ps举例:假定 文档中的一个剧本执行以下语句:
document.domain = "company.com";
这条语句执行之后,页面将会奏效地通过与 的同源检测(假定 将其 document.domain 开荒为“company.com”,以标明它但愿允许这么作念——更多相干信息,请参阅 document.domain)。然则,company.com 不可开荒 document.domain 为 othercompany.com,因为它不是 company.com 的父域。
端标语是由浏览器另行检讨的。任何对 document.domain 的赋值操作,包括 document.domain = document.domain 齐会导致端标语被袒护为 null 。因此 company.com:8080 不可仅通过开荒 document.domain = "company.com" 来与 company.com 通讯。必须在它们两边中齐进行赋值,以确保端标语齐为 null 。
该机制有一些局限性。要是启用了 document-domain Permissions-Policy,或该文档在沙箱 <iframe> 下cosplay 足交,它将抛出一个“SecurityError” DOMException,况且用这种才智改造源并不影响 Web API 使用的源检讨(举例 localStorage、indexedDB、BroadcastChannel、SharedWorker)。更老成的失败案例列表不错在 Document.domain 的子虚章节找到。