javascript - 设置 document.domain 是否适用于所有(大多数)浏览器?

标签 javascript browser cross-browser

Same Origin Policy Documentation是这样说的:

There is one exception to the same origin rule. A script can set the value of document.domain to a suffix of the current domain. If it does so, the shorter domain is used for subsequent origin checks. For example, assume a script in the document at http://store.company.com/dir/other.html executes the following statement:

document.domain = "company.com";

After that statement executes, the page would pass the origin check with http://company.com/dir/page.html. However, by the same reasoning, company.com could not set document.domain to othercompany.com.

所有流行的浏览器都支持吗?如果不是,哪些不是?

最佳答案

Firefox 2,3, IE6,7,8, Chrome, Safari 2 和 3, Opera 9 都支持 document.domain;

其他“较新”的浏览器也可能会,但是那些是我实际测试过我的代码(使用 document.domain)的浏览器

关于javascript - 设置 document.domain 是否适用于所有(大多数)浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/745831/

相关文章:

cross-browser - 将CrossRider用作开发多个浏览器扩展的平台有哪些缺点?

javascript - 有没有办法让 Internet Explorer 理解 this.style.setProperty?

javascript - android 2.2 浏览器在 ontouchend 事件中不工作 pageY 或 PageX

asp.net-mvc - 尝试使用 SignalR 检测浏览器关闭事件

css - 元素符号列表项总是缩进 1.8em 吗?

html - 剩余可用空间 HTML 的高度

html - 速记动画仅适用于 Chrome

javascript - 使用 js-xlsx 导出 .xlsx 文件时如何设置单元格宽度

javascript - 有条件地更新 React Json 值

javascript - 网站可以在除 Opera 和 IE9 或更早版本之外的所有浏览器中运行吗?