Use HTML5 new feature to change browser address without refreshing page __html

Source: Internet
Author: User

Http://www.cnblogs.com/xuchengzone/archive/2013/04/18/html5-history-pushstate.html

As a programmer, GitHub must be a very regular thing. Careful students will find that when we browse the project source code, after entering the folder URL address changes, the content will soon be loaded well. At first I thought it was refreshing the page load, but the speed of refreshing the page is too fast. So F12 monitored the network request and found it was an AJAX request. is very magical, the URL address changes will not refresh the page (#号后面的除外啦). What's the situation. Conjecture must be a new feature of the HTML5. Google search is really the case, is history.pushstate this new thing. So the automatic hands-on test was realized.

To achieve the effect as shown, click on the crumbs to navigate the contents of the content of Ajax loading page.

MVC page Code, AJAX request simply returns a content

<! DOCTYPE html>  

Summary: Just look at the data to see the time that is called a JS can be done, but when you do demo will find a problem, such as: Browser forward back when the page does not update, solve the update and found back to enter the first page when there is a problem, and finally through

History.replacestate this to achieve, so as to achieve similar GitHub source file loading similar effect.

Demo Source Download


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.