document.location和window.location有什么区别啊?
我大部分情况下是使用window.location
但是发现别人有使用document.location的,不知道二者有什么区别?
还有就是document.locationdocument.location.href和document.location.href有什么区别?
window.location和window.location.href有什么区别?有的书上还提到了document.URL这个属性,document.URL
又是做什么的?貌似是跟document.location作用一样,
请高手指点一下!谢谢!!!

解决方案 »

  1.   

    记得有JS高级设计上有说,document.location和window.location是一样D 
      

  2.   

    见此http://www.cnblogs.com/nuke/archive/2009/01/03/1367565.html
      

  3.   

    试验一下L@_@K
    alert(document.location === window.location); // true
      

  4.   

    你这个问题实际上就是问window对象和document对象的区别嘛
    一般来讲,一个window里就是一个document,但是,iframe里面也可以装个document,在iframe里面就有区别了
      

  5.   

    document.location="url";(只读)
    document.location.reload("url";);
    window.location="url";
    location="url";
    document.href="url"
    document.location.href="url"
    document.location.replace="url"
    document.action="url"; document.submit();document.location.href和document.location.replace都可以实现从A页面切换到B页面,但他们的区别是:
    用document.location.href切换后,可以退回到原页面。而用document.location.replace切换后,不可以通过“后退”退回到原页面。
    关于document.location.href或其他可回退的切换方式
    document.location 相当于 document.URL 声明了装载文档的URL,
    除非发生了服务器重定向, 否则该属性的值与Window.location.href的值是一样的.history.go(-1);//返回上一页
    document.IFRAME名称.location.href='url';//改变框架内容 
      

  6.   

    document.location和window.location有什么区别就是
    document你可以理解为文档,就是你的网页
    window理解为窗口,就是你的ie浏览器包含的无框架:简单的说,没有框架的情况下,是等同的
    有框架:在有框架的情况下,最外层是相同的,在iframe里面的document.location和window.location不同的。
    iframe里面的document.location 你看不ie地址变化,只改变iframe部分,
    此时的window.location和top.location效果一致
      

  7.   

    没有区别,document.location是老标准。新标准规定location对象是全局对象,也就是挂在window对象下。
      

  8.   

    JavaScript原文摘录:
      不要混淆Window对象的location属性和Document对象的location属性。前者引用一个Location对象,而后者只是一个只读字符串,并不具有Location对象的任何特性。document.location与document.URL是同义的,后者在JavaScript1.1中是该属性的首选名称(因为这样避免了潜在的混淆)。在大多数情况下,document.location和location.href是相同的。但是,当存在服务器重定向时,document.location包含的是已经装载的URL,而location.href包含的则是原始请求的文档的URL。
      

  9.   

    是JavaScript权威指南 原文摘录
      

  10.   

    我没有用框架,但是用window.location不跳转,用document.location可以 
      

  11.   

    document.location is deprecated in favor of window.location, which can be accessed by just location, since it's a global object.The location object has multiple properties and methods. If you try to use it as a string then it acts like location.href. To be on the safe side it's best to always use location.href when that's what you mean.
      

  12.   

    $(window).width()
    $(document).width()啥区别啊?