document represents a document object, and windows represents a window object.
There can be many document objects under one window. Every document has a URL.
But that’s not all the difference. When you ctrl F5 a link http://www.jb51.net/#server
print alert(document.URL); and alert(windows.location.href);
found that the values of these two are not the same Same,
document.URL: http://www.jb51.net/
windows.location.href: http://www.jb51.net/#server
So , if you want to use fragment for corresponding processing, it is best to use windows.location.href
otherwise strange errors will occur.