The main methods for transferring values between two pages in the PC web application include cookie, query string, and data exchange through session on the server side. But what about the value transfer method of the app?
Since the app is basically a single page method, the string query method does not seem to work. At least I have not seen such an example yet ..
Mainly includes 1HTML5 LocalStorage local storage, 2 hidden fields, 3 extended attributes, and 4 server-sideSession, etc.
1HTML5 LocalStorage Local Storage
This method is similar to the cookie method, and is a new standard of html5. In HTML5, local storage is a window attribute, including localStorage and sessionStorage,
The former always exists locally, and the latter is only accompanied by the session. Once the window is closed, it will be gone.
Reference
2. Hide Fields
In PC web programs, hidden fields are often used to store specific information. They can also be used in apps. Of course, there are certain restrictions. values can be transferred in single-page apps, because a single page will eventually become the same dom in the memory, you can set hidden fields in one panel and read hidden fields in another panel.
For example:
Set the value of hidden fields on the jiekuanshenpi.html page and read the value of hidden fields in jiekuanshenpidetail.html.
3. extended attributes
The restrictions and causes are the same as those for hidden fields.
For example:
The above Code adds an extended property jiekuanshenpiDetailId
On the jiekuanshenpi.html page, set the value of the extended property jiekuanshenpiDetailId,
$("#jiekuanshenpiDetail").attr("jiekuanshenpiDetailId",id);
Read the value of jiekuanshenpidetail.html.
var jiekuanshenpiDetailId2 = $("#jiekuanshenpiDetail").attr("jiekuanshenpiDetailId");
4. Server session
This is basically the same as the text on the PC end, and the value transfer method on the server end can be basically used.