methods of jquery and JS Operation Localstorage/sessionstorageLocalstorage
- is the optimization of cookies
- Data storage with no time limit
- Not readable in privacy mode
- Size limit is around 5 million characters, each browser is inconsistent
- Shared in all homologous windows
- The essence is to read and write files, the number of data will compare cards (Firefox will import data into memory at a time)
- Cannot be crawled by crawlers, do not use it to completely replace URL parameters
- IE7 and below are not supported, other standard browsers are fully supported
Sessionstorage
- Data storage for a session
- Size limit is around 5M, each browser is inconsistent
- Valid only until the current browser window is closed (for session validation)
- Not shared in different browser windows, even on the same page
How to operate under JS
- Get key value: Localstorage.getitem ("key")
- Set key value: Localstorage.setitem ("Key", "value")
- Clear key value: Localstorage.removeitem ("key")
- Clear all Key values: Localstorage.clear ()
- Gets the key value 2:localstorage.keyname
- Set key Value 2:localstorage.keyname = "Value"
Operation Method under JQ (JS method before adding "window.") )
- Get key value: Window.localStorage.getItem ("key")
- Set key value: Window.localStorage.setItem ("Key", "value")
- Clear key value: Window.localStorage.removeItem ("key")
- Clear all Key values: Window.localStorage.clear ()
- Gets the key value 2:window.localstorage.keyname
- Set key Value 2:window.localstorage.keyname = "Value"
Demo
<!DOCTYPE HTML><HTML><HeadLang= "en"> <MetaCharSet= "UTF-8"> <title></title> <Scripttype= "Text/javascript"CharSet= "Utf-8"src= "Js/jquery.min.js"></Script> <Scripttype= "Text/javascript"> //JS Operation sectionLocalstorage.jsa="JSA"; document.write (LOCALSTORAGE.JSA); Localstorage.setitem ('JSb',' JSB'); document.write (Localstorage.getitem ('JSb')); //jquery Operations Section $(function() {window.localStorage.JQa="JQA"; $("#a"). Text (window.localStorage.JQa); Window.localStorage.setItem ('JQb','JQB'); $("#b"). Text (Window.localStorage.getItem ('JQb')); }); </Script></Head><Body> <PID= "a"></P> <PID= "B"></P></Body></HTML>
Methods of jquery and JS Operation Localstorage/sessionstorage