Introduction
The 1th section describes how to develop basic albums using Sajax, PHP, and JavaScript. In the process of building a historical stack for your application, we will rely on client-side technology and combine it directly with the code in part 1th. This article assumes that the reader understands JavaScript and browser cookies.
Save state in Browser
When surfing the web, always from one page to another page, from one site to another site. In this process, the Web browser faithfully records the history of where you have been, creating a breadcrumb-shaped (breadcrumbs) digital trajectory that can step back to the starting point along this trajectory. The Back button allows you to go back to where you were before the previous action, and in that sense it is the Undo button on the web.
The Web is a page-separated media. The back and forward buttons in the browser toolbar guide the browser from one page to another. When Macromedia's flash popular, developers and users discovered that rich Internet applications (the Rich Internet Application,ria) broke this pattern. Users can browse through several sites and then log on to a Flash-based website and spend a few minutes on the site. When the user clicks the Back button, the game is over. The user did not go back to the previous flash site and had no idea where it was.
This is also true for another form of--ria, a completely AJAX-based site. Sites that allow users to interact with a page more than once are susceptible to back buttons, or are plagued by any history buttons (in this case). The problem with the forward and reload buttons is the same as the back button. The internal history mechanism built into the Web browser is an inescapable problem. For security reasons, developers cannot tamper with browser history or any related buttons. There is also the question of usability. Imagine how confusing a user should be if the back button pops up with a mysterious warning prompt or if the user is sent to a new website.
Build a history stack
Although you can't change your browser history, you can build your own history for use in Ria. Obviously, it should be somewhat separate from the browser's standard navigation tools, but as mentioned earlier, rich applications deviate to a certain extent from the Web's standard mode of page-to-page.
We will create a stack to manage the historical event records of the application, that is, to store a list, adding elements at the end of the table. Stacks are used to store data in last in, first out (LIFO) order. Although the data at the top of the stack was not deleted at the time of rollback, this model is very close to our needs. In JavaScript, stacks can be managed with arrays.
There is also a pointer to the stack that indicates our current position in the stack. When we click in the application, the new event is pressed onto the top of the stack, and the pointer points to the last element added. When you click the application's back and Forward buttons, no new events are added to the stack, but pointers to the stack are moved. Think about what happens in the history stack when you use the Back button: The browser returns to the last page viewed, and the forward button that was not used suddenly becomes available. When you browse a new page, the forward button turns gray again. Later saved elements in the browser history are ejected from the stack, and new events are pressed onto the top of the stack. We will reproduce this behavior in the history stack that we created.
Our goal is to create a set of available history buttons: Back, forward, and refresh, as shown in 1.
http://www.bkjia.com/PHPjc/446841.html www.bkjia.com true http://www.bkjia.com/PHPjc/446841.html techarticle The 1th section describes how to develop basic albums with Sajax, PHP, and JavaScript. In the process of building a history stack for your application, we will rely on client-side technology and direct it ...