设置document.domain是否适用于所有(大多数)浏览器? [英] Does setting document.domain work in all (most) browsers?

查看:323
本文介绍了设置document.domain是否适用于所有(大多数)浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同源政策文档说明了这一点:


同一
来源规则有一个例外。脚本可以将document.domain的
值设置为当前域的后缀
。如果它这样做,
较短的域用于
后续原产地检查。例如,
假定文档中的脚本为
http:// store .company.com / dir / other.html
执行以下语句:

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;

document.domain = "company.com";


语句执行之后,页面
将通过
http://company.com/dir/page.html
但是,出于同样的原因,
company.com无法将
document.domain设置为othercompany.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.

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

Do all popular browsers support this? If not, which ones don't?

推荐答案

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

Firefox 2,3, IE6,7,8, Chrome, and Safari 2 and 3, Opera 9 all support document.domain;

其他更新的浏览器也可能会这样,但是那些是我实际测试过的代码(它利用了document.domain)

Other "newer" browsers likely will as well, however those are the ones that I've actually tested my code (which makes use of document.domain)

这篇关于设置document.domain是否适用于所有(大多数)浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆