Home >Web Front-end >JS Tutorial >What is the usage of window.location.href?

What is the usage of window.location.href?

青灯夜游
青灯夜游Original
2020-04-23 15:01:4815289browse

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"

2. Open the URL page on the parent page.

parent.location.href="url"

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

top.location.href="url"

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!

Statement:
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