admin管理员组文章数量:1316980
while using document cookie
<script typ="text/javascript">
document.domain="example";
</script>
I got an error.i don't know the exact problem.
Error: uncaught exception: [Exception... "Illegal document.domain value" code: "1009" nsresult: "0x805303f1 (NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN)" location: ""]
while using document cookie
<script typ="text/javascript">
document.domain="example.";
</script>
I got an error.i don't know the exact problem.
Share Improve this question edited Feb 3, 2012 at 7:44 Ateş Göral 140k27 gold badges141 silver badges191 bronze badges asked Feb 3, 2012 at 7:34 user1186966user1186966 431 gold badge1 silver badge3 bronze badgesError: uncaught exception: [Exception... "Illegal document.domain value" code: "1009" nsresult: "0x805303f1 (NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN)" location: ""]
2 Answers
Reset to default 5According to the HTML spec, document.domain
is read-only. However, Firefox allows setting it to a superdomain:
https://developer.mozilla/en/document.domain
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 it is possible to set it to "mozilla" but not "mozilla." or "org".
The error you're getting clearly states that you're making an illegal domain assignment.
You mention cookies in your question. If you're trying to set the domain part of a cookie, setting document.domain
has nothing to do with it. You need to provide a domain parameter as part of the cookie string that you're assigning:
document.cookie = "foo=bar;domain=example.";
More info here: https://developer.mozilla/en/DOM/document.cookie
it works on IE as well. it's for same origin, we need to shorten the domain name.
本文标签: javascriptdocument cookieGot an error quotIllegal documentdomain valuequotStack Overflow
版权声明:本文标题:javascript - document cookieGot an error "Illegal document.domain value" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741999767a2410769.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论