Home > Web Front-end > JS Tutorial > body text

What is the usage of window.location.href?

青灯夜游
Release: 2020-04-23 15:01:48
Original
15222 people have browsed it

What is the usage of window.location.href?

window.location object can be used to obtain the current page address (URL) and redirect the browser to a new page.

The window.location object can be written without the window prefix.

window.location.href

##window.location.href property returns the URL of the current page.

In js,

window.location.href is often used for page jumps. It mainly has the following usages:

1. Open the URL page on the current page.

It should be noted that

window.location.href=window.location.href and window.location.reload() both refresh the current page. The difference lies in whether data is submitted. When data is submitted, window.location.Reload() will prompt whether to submit it, window.location.href=window.location.href; is to submit data to the specified url

self.location.href="url"
location.href="url"
window.location.href="url"
this.location.href="url"
Copy after login

2. Open the URL page on the parent page.

parent.location.href="url"
Copy after login

3. Open the URL page on the top-level page.

top.location.href="url"
Copy after login

Recommended tutorial:

js tutorial

The above is the detailed content of What is the usage of window.location.href?. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!