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

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

Should both of them reference the same object?

16条回答
  •  眼角桃花
    2020-11-22 13:36

    I would say window.location is the more reliable way of getting the current URL. Following is the difference between the window.location and document.url that came in front in one of the scenarios where I was appending hash parameters in the URL and reading it later.

    After adding hash parameters in the URL.

    In an older browser, I was not able to get the hash parameters from the URL by using document.url, but when I used window.location then I was able to get the hash parameters from the URL.

    So it's always better to use window.location.

提交回复
热议问题