Home > Web Front-end > H5 Tutorial > How to use popstate? Summary of popstate instance usage

How to use popstate? Summary of popstate instance usage

零下一度
Release: 2017-06-12 13:43:21
Original
5781 people have browsed it

This article mainly introduces the history of pushstate and popstate operations of HTML5, and the relevant information about changing the current URL without refreshing. Friends in need can refer to the next step. Understanding window.historywindow.history represents the history of the window object, which is determined by the user. A global object that is actively generated and controlled by JavaScript scripts. The window object provides access to the browser history through the history object. It exposes some very useful methods and properties that allow you to move forward and backward freely in the history. 1. Forward and Backward in History To go back in history, you can do this: window.history.back(); This is just like the user clicking the back button of the browser. Similarly, you can move forward, just like clicking the forward button in the browser, like this: window.history.forward(); 2. Move to a specified history point by specifying a value relative to the current page position, you can use The go() method loads the page from the history of the current session

1. Detailed introduction to the pushstate and popstate operations of HTML5 history without refreshing to change the current url

How to use popstate? Summary of popstate instance usage

Introduction: This article mainly introduces the history of pushstate and popstate operations in HTML5, and related information about changing the current url without refreshing. Friends who need it You can refer to the following

2. Detailed explanation of the pushstate and popstate operations history of HTML5 without refreshing and changing the current url code example

How to use popstate? Summary of popstate instance usage

Introduction: This article mainly introduces the history of pushstate and popstate operations in HTML5, and related information about changing the current url without refreshing. Friends who need it can refer to it

3. Click back on the JQ page and a prompt box will pop up

How to use popstate? Summary of popstate instance usage

## Introduction: demo.js jQuery(document).ready(function ($) { if (window.history && window.history.pushState) { $(window).on('popstate', function () { var hashLocation = location.hash; var hash ...

##4.

Use pushState, popState and location.hash to implement a small route yourself

How to use popstate? Summary of popstate instance usage##Introduction: This article mainly records the pushState and replaceStateAPI provided by history in HTML5. Finally, you can implement small routing by yourself through these APIs.

5.

Create a better browsing experience-HTML5 history API

Introduction: HTML5 history API only includes 2 Methods: history.pushState() and history.replaceState(), and 1 event: window.onpopstate. ,.

[Related Q&A recommendations]:

javascript - WeChat popstate event, how to solve the rollback event and cancel the init initialization data

javascript - How to display the value of the url parameter obtained by js on the arcgis server map?

javascript - Can't get the state of the onpopstate event?

javascript - How to use ajax to change the web page address (url) without refreshing Implement forward and backward to change content?

javascript - chrome back forward button does not trigger onpopstate event

The above is the detailed content of How to use popstate? Summary of popstate instance usage. For more information, please follow other related articles on the PHP Chinese website!

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