Use ajax and history. pushState to change the page URL and history. pushstatePerformance
If you use chrome or firefox to access this blog, github.com, plus.google.com, and other websites, you will find that the clicks between pages are requested asynchronously through ajax, at the same time, the page URL has changed. In addition, the browser can be well supported
passing URL parameters to the go () method.2. Adding and modifying a history entityfrom Gecko2 Start Introducing (Firefox 4/thunderbird 3.3/seamonkey 2.1)HTML5 introduces two methods, histtory.pushstate () and history.replacestate (), which allow you to add and modify history Entities. At the same time, these methods work with the Window.onpostate Event.Use the History.pushstate () method to modify the ref
a history entityIntroduced since Gecko2 (Firefox 4/thunderbird 3.3/seamonkey 2.1)HTML5 introduces two methods, Histtory.pushstate () and History.replacestate (), which allow you to add and modify history entities. At the same time, these methods work with the Window.onpostate event.Use the History.pushstate () method to modify the referrer, which can be used in the HTTP header created for the XMLHttpReque
New HTML5 history features pushState and replaceState, and their differences. html5pushstateThe window object in DOM reads the browser's historical records through the window. history method, allowing you to forward and backward in the user's access records.Starting from HTML5, we can start to operate this history stac
Pushstate method One, recognize Window.historywindow.historyRepresents the history of the Window object, which is generated by the user and accepts the global object controlled by the JavaScript script. The Window object history provides access to the browser history through the object. It exposes some very useful meth
First, this article is an example showThree:
I just want to find an example, know how to use, use grammar and so on roll rough
With the search engine.
Own memo
Energy is always limited, yesterday an impulse, outside the Shanghai Pudong outside the ring booked a 90 meters house, to borrow money to raise down payment, loans and certificates and so on. HTML5 History related Knowledge points Phala Phala speak up is also a smelly and
First, this article is an example showThree:
I just want to find an example, know how to use, use grammar and so on roll rough
With the search engine.
Own memo
Energy is always limited, yesterday an impulse, outside the Shanghai Pudong outside the ring booked a 90 meters house, to borrow money to raise down payment, loans and certificates and so on. HTML5 History related Knowledge points Phala Phala speak up is also a smelly and
Detailed description of HTML5 pushstate and popstate operations history, without refreshing changes to the current url, html5pushstate
I. Know window. history
Window. history indicates the history of the window object. It is a global object generated by the user and controll
Javascript advancedProgramAs mentioned in design (version 2), location. Path/query in Bom ...... (Window. Location) after being changed through JavaScript, the browser will refresh the URL you changed (location means location ..)
Since JavaScript MVC began to become popular, the method of modifying the URL through refresh made people feel annoyed. However, HTML5 creates an API that can be used to modify the URL without refreshing the browser, that is, the
PushState, replaceState, and onpopstate are used to refresh the Ajax page forward and backward. history. replacestate
Ajax can be used to obtain data asynchronously and render pages more efficiently.
However, these problems also exist:
Refresh the page and the page will become the initial state.
The browser's forward and backward functions are invalid.
Unfriendly to crawling by search engines
1,
Previously,
First, this article is an example showThree:
I just want to find an example, know how to use, use grammar and so on roll rough
With the search engine.
Own memo
Energy is always limited, yesterday an impulse, outside the Shanghai Pudong outside the ring booked a 90 meters house, to borrow money to raise down payment, loans and certificates and so on. HTML5 History related Knowledge points Phala Phala speak up is also a smelly and
by Zhangxinxu from http://www.zhangxinxu.comThis address: http://www.zhangxinxu.com/wordpress/?p=3432First, this article is an example showThree:
I just want to find an example, know how to use, use grammar and so on roll rough
With the search engine.
Own memo
Energy is always limited, yesterday an impulse, outside the Shanghai Pudong outside the ring booked a 90 meters house, to borrow money to raise down payment, loans and certificates and so on. HTML5
I. Ajax onboarding and browser history forward and backwardAs we all know, Ajax can achieve the non-flush operation of the page-the advantages, but also cause other problems, can not go forward and backward! Once upon a while, Gmail seemed to be using an iframe to fix it, and now HTML5 makes things as simple as a house.When performing an AJAX operation, history plug an address (used) into the browser
HTML5 history has added two properties, namely Replacestate () and Pushstate (), and does not refresh the URL of the page change page.Replacestate () Can change URLs without a page refreshUsage: History. Replacestate("Data","title of page","changed url") PS: the title of some pages can not be changed after testingPushstate () is a record of inserting a UR
Use the history. pushState () and popstate events to implement the AJAX forward and backward functions. pushstateajax
In the previous article, we used location. hash to simulate the ajax forward and backward functions. Using location. hash has the following problems:
1. Using location. hash will change the url in the address bar and the user experience is unfriendly.
2. historical records generated by locat
enter function $ (document). Bind ("keydown", function (e) {if (event.keycode==116) { event.keyCode=0; event.cancelBubble= true; return false; (}});});and the underlying grammatical differences of "pushstate" and "replacestate": history.pushstate (state, title, url) Adds the current URL and history.state to the history and replaces the current with the new state and Url.does not cause page Refreshes.Sta
This paper is the official HTML5 training course for Brother Lian it educational institution, mainly introduces: HTML5 new features "Pushstate" and "Replacestate"Recently, when dealing with the browser disable brush function, a new attribute is used: history.pushstate ();The official explanations are as follows:The History.pushstate () method and the History.replacestate () method allow you to add and modify histo
PushState implements no-refreshing Ajax page switching and pushstateajax
Preface
This is a common requirement: Click the page number to partially update the page (not to refresh the page as a whole), and generate historical management. Partial refresh is easy to implement. ajax can meet our needs, but it does not produce History Management. Fortunately, html5 provides us with several useful APIs to solve th
Achieve the goal
Page jump (forward back, click, etc.) do not request the page again
The page URL is consistent with the content of the page presentation (in line with people's understanding of traditional Web pages)
In a way that does not support the descent of browsers into traditional Web pages
API to use
History.state
The corresponding state information under the current URL. If the current URL is not generated through pushstate or replacest
SPA (Single Page Application) is short for SPA. Applications built using SPA have good user experience and high speed, so you do not need to reload the entire Page for content changes, this avoids unnecessary jump and repeated rendering, which reduces the server pressure. SPA is widely used on mobile WEB terminals.In the previous article, we used Javascript to implement the frontend routing mentioned in the simple frontend routing. Without refreshing the entire page, we can transform the hash in
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.