Home > Article > Web Front-end > AJAX web pages retain browser forward and backward functions_javascript skills
In some pages where AJAX is heavily used, sometimes you don't dare to refresh, because after refreshing, you may see a page that is very different from the original one. Let's not discuss the issue of whether to use AJAX when the content of certain pages is updated a lot. This article will briefly talk about retaining the browser's forward, backward, refresh and other functions.
Here we assume a page with two Tabs, each containing a large amount of text and possibly pictures. If you feel that the content of Tab2 is good now, add it to your favorites or send it to a friend. Next time you open it through favorites or a friend clicks on this link, you will most likely see the content of Tab1, and then you need to click Tab2 again to see the content you want to see. If the page logic is more complex, you may need to perform multiple steps to return to the content you want to see, which is not a good experience.
For functions such as refreshing and adding to favorites to work properly, the current operation needs to be reflected in the URI. However, changing the URI does not cause the page to refresh, so it can be achieved by changing the fragment in the URI. For example, clicking Tab1 will change the URI to http://www.example.com/example.html#tab1, and clicking Tab2 will change the URI to http://www.example.com/example.html#tab2.