在看别人的代码过程中,见到了好几次对document.domain
进行的赋值操作,就像下面这样:
document.domain='hao.com';
但是我再查手册的过程中了解到
书上说document.domain是只读的,返回为一个字符串。
但是有的人为什么还要这样做呢?
有什么作用?难道不会报错吗?
还是有的浏览器支持此操作啊?
再或者是利用了浏览器的Bug?

解决方案 »

  1.   

    http://cache.baidu.com/c?m=9d78d513d9951cfe1fb2c3224b01d6160e54f7743da786482087c81487231b1f483ca5fd65351177ced8263c16af3e0cb9ab6035200357e6c697951286e8ce7d71db7b616d4cd81c47ce42e99c1938c42b915bedab1de5bdf333c7f884d5da03039e59517086f19c5a774e8c30ae&p=c0769a418d9c15ff57e9922c580d&user=baidu
      

  2.   

    domain Property  
    Sets or retrieves the security domain of the document. Syntaxdocument.domain [ = sDomain ]
    Possible ValuessDomain String that specifies or receives the domain suffix. The property is read/write. The property has no default value.
      

  3.   

    可是W3School说此属性是一个只读的字符串。
    请看如下地址:
    document.domain
      

  4.   

    貌似在W3C DOM L1中的定义是只读:
    http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html#ID-2250147
    interface HTMLDocument : Document {
    ........................
      readonly attribute  DOMString            domain;
    ........................
    };在Mozilla的开发者文档中和MS的DHTML手册中都是读/写https://developer.mozilla.org/en/DOM/document.domain
    document.domain
    Gets/sets the domain of the current document.