# document.location.href和document.location有什麽區別？

document.location.hrefdocument.location 之間有什麽區別？

## 最佳答案

document.location is a synonym for window.location that has been deprecated for almost as long as JavaScript has existed. Don't use it.

location is a structured object, with properties corresponding to the parts of the URL. location.href is the whole URL in a single string. Assigning a string to either is defined to cause the same kind of navigation, so take your pick.