。Cookie文件/得到一個錯誤「非法document.domain的值」
Error: uncaught exception: [Exception... "Illegal document.domain value" code: "1009" nsresult: "0x805303f1 (NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN)" location: ""]
。Cookie文件/得到一個錯誤「非法document.domain的值」
Error: uncaught exception: [Exception... "Illegal document.domain value" code: "1009" nsresult: "0x805303f1 (NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN)" location: ""]
根據HTML規範,document.domain
是隻讀的。不過,Firefox允許其設置爲超級域:
https://developer.mozilla.org/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.org it is possible to set it to "mozilla.org" but not "mozilla.com" or "org".
你清楚地得到的錯誤說你讓一個非法域分配。
您提到您的問題的曲奇。如果您嘗試設置Cookie的域名部分,則設置document.domain
與此無關。您需要提供一個域參數作爲cookie字符串的一部分,你分配:
document.cookie = "foo=bar;domain=example.com";
它適用於IE瀏覽器也是如此。它的起源相同,我們需要縮短域名。