document.domain="example.com"; ...">

Document cookie / Received error "Invalid document.domain value"

when using cookie

<script typ="text/javascript"> document.domain="example.com"; </script> 

I have a mistake. I do not know the exact problem.

Error: uncaught exception: [Exception ... "Invalid document.domain value" code: "1009" nsresult: "0x805303f1 (NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN)" location: ""]

+4
source share
2 answers

According to the HTML specification, document.domain is read-only. However, Firefox allows you to install it in a superdomain:

https://developer.mozilla.org/en/document.domain

The HTML DOM specification specifies this property as read-only. However, Mozilla will allow you to set it to the superdomain current value, limited to its base domain. For example, on developer.mozilla.org you can install it on "mozilla.org", but not on "mozilla.com" or "org".

The error you receive clearly states that you are making an illegal domain assignment.

You indicate cookies in your question. If you are trying to set the domain part of the cookie, setting document.domain has nothing to do with it. You need to specify the domain parameter as part of the cookie string that you assign:

 document.cookie = "foo=bar;domain=example.com"; 

More details here: https://developer.mozilla.org/en/DOM/document.cookie

+5
source

It works with IE. it is for the same origin, we need to shorten the domain name.

0
source

Source: https://habr.com/ru/post/1394555/


All Articles