What's the difference between [removed] and [removed] in JavaScript?

后端 未结 16 1973
故里飘歌
故里飘歌 2020-11-22 12:37

Should both of them reference the same object?

16条回答
  •  清酒与你
    2020-11-22 13:31

    The canonical way to get the current location object is window.location (see this MSDN page from 1996 and the W3C draft from 2006).

    Compare this to document.location, which originally only returned the current URL as a string (see this page on MSDN). Probably to avoid confusion, document.location was replaced with document.URL (see here on MSDN), which is also part of DOM Level 1.

    As far as I know, all modern browsers map document.location to window.location, but I still prefer window.location as that's what I've used since I wrote my first DHTML.

提交回复
热议问题