In the daily operation process, it is unavoidable to use JavaScript in the user's browser to store some data locally, to achieve some can not use the server to identify functions, such as the identification of the user's second visit. Commonly used methods have Cookie,ie browser UserData, as well as Localstorage, because the UserData only IE support, its scalability is not large.
Cookie
The advantage of c
HTML5 Localstorage Local StorageWhen it comes to local storage, it's been a long walk to HTML5 , and the previous history is probably as Follows: The earliest cookie is naturally known to all, the problem is mainly too small, probably also 4KB
Localstorage.setitem (att) automatically stores att as a string, such as:
The code is as follows
Copy Code
var arr=[1,2,3];Localstorage.setitem ("temp", arr);typeof Localstorage.getitem ("temp"); Returns a
This article mainly introduces essential tips for mobile phone Development: javascript and CSS code sharing. This article describes viewport (visible area) operations, Link Operations, javascript events, and so on, for more information, see
1. viewport:
That is, the visible area. For desktop browsers, we all know what the viewport is, that is, the area used to view the webpage after all the toolbar, Status
Detailed description of cacheStorage in JavaScript and javascript Closure
Should localStorage be a household name? But the local storage family can be far more than it. I used sessionStorage before, and now there is a magic CacheStorage. It is used to store Response objects. That is to say, it is used to Cache HTTP and response. Although
that the user sees.
Browser Engine: Handles interaction between the user interface and the rendering engine
Rendering Engine: responsible for displaying Web pages. The rendering engine parses the HTML and CSS and displays the parsed content on the screen.
Network: Network calls initiated by different implementations of each platform, such as XHR requests, are implemented on a cross-platform interface.
UI backend: Responsible for drawing core parts such as check boxes and Windows
Today's app,android and H5 hybrid development is common. When Android loads the H5 page through WebView and needs to be passed to it, it can be done with loaclstorage. The code is as follows:WebView first set the following
New function () {var ws = Null;var connected = False;var Serverurl;var connectionstatus;var sendmessage;var connectbutton;v AR Disconnectbutton; var Sendbutton;var open = function () {var url = serverurl.val (); ws = new WebSocket (URL); ws.onopen =
Note: Reference sources with no title but pages are referred to as the sixth edition of the JavaScript Authority guide, and other references have title or URL annotations.One, easy to produce misunderstanding knowledge point record1, [] = =! []All objects are converted to True (P52), and the array is an object, so an empty array [] converts to a Boolean value to be true. An empty array is 0 when converted to a number. Therefore, the left digit ([]) =
reserved character needs to be matched.
For example, we want to match an ABC start, ABC end, the middle of an open-ended string: reg=/^ (ABC) [a-z]*\1$/; You can put this sentence in the example just now to try, I tested there is no error.
Several common matching regular types:
1. Date of match: reg=/^\d{4}-((0[13578]|) ( 10|12))-(0[1-9]|[ 1-2]\D|3[01]) | (02-(0[1-9]) | [1-2]\d) | ((0[469]|11)-(0[1-9]|[ 1-2]\d|30)) $/g;
2. Match time: reg=/^ ([0-1]\d|[ 2][0-3] (:([0-5]\d)) {2}$/g;
3. Matching m
specified on the ①localstorage, and the rules are set beforehand. In order to access the same Localstorage object, the page must come from the same domain name (invalid subdomain), using the same protocol, on the same port.
② data remains to be deleted through JavaScript or the user clears the browser cache.
Case:
Localstorage.setitema ("name", "Nicholas");
Loca
This article examples for everyone to share a simple JavaScript, jquery practical demo, for your reference, the specific contents are as follows
JavaScript Judge H5 Page left
function Onbeforeunloadfn () {
console.log (' leave page ');
... code
}
function Showonbeforeunload (flags) {
if (flags) {
document.body.onbeforeunload = ONBEFOREUNLOADFN;
} else{
document.body.onbeforeunload = null;
}
I always wanted to implement mac.pcbeta.com's skin function. Recently, I wrote a javascript code to save the skin name set by the user to localstorage. Every time I refresh the page, I call the field stored in localstorage, then reference the CSS file contained in the new skin according to the field .... I always wanted to implement mac.pcbeta.com's skin function
Tips for mobile development: javascript and CSS code sharingThis article mainly introduces essential tips for mobile phone Development: javascript and CSS code sharing. This article describes viewport (visible area) operations, Link Operations, javascript events, and so on, for more information, see
1. viewport:
That is, the visible area. For desktop browsers,
This article mainly introduces how to use javascript to convert mouse arrows into a candle burning effect. The example shows how to use javascript to operate mouse events and images, which has some reference value, for more information about how to use JavaScript to convert the mouse arrow into a candle burning effect, see the example in this article. Share it wi
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.