Home > Web Front-end > JS Tutorial > The difference between document.URL and windows.location.href in JS_javascript skills

The difference between document.URL and windows.location.href in JS_javascript skills

WBOY
Release: 2016-05-16 18:42:03
Original
1119 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template