Appcan Local storage for introductory learning Locstorage

Source: Internet
Author: User

Local Storage Locstorage

Method:

1.appcan.locstorage.getval (Key) gets the value that the key holds in the Localstorage

// gets the saved color

appcan.locStorage.getVal (' color ');// returns the saved color value

2.appcan.locstorage.setval (Key, Val) to set the key-value pair

// set a color to local storage

Appcan.locStorage.setVal (' Color ', ' red ');

3.appcan.locstorage.val (Key,value) Gets or sets the value of the Localstorage

// get all keys saved in Localstorage

varvalue = Appcan.locStorage.val (' k ');// The return value is an array that contains all the key

4.appcan.locstorage.remove (Key) clear the corresponding value in Localstorage

// Clear saved color values

Appcan.locStorage.remove (' color ');

5.appcan.locstorage.keys () gets all the key values that are saved in the Localstorage

// get all keys saved in Localstorage

Varkeys = Appcan.locStorage.keys ();// The return value is an array that contains all the key

Cases:

Page1_content.html

Add Input box and button

<!--- Insert Search Input box --->

<div class= "sc-bg-active uinput ubub-f1   Bc-border uba ">            <div  class= "Uinn fafa-search sc-text" ></div>             <input placeholder= "Please enter search content"  type= "text"  class= "Ub-f1"  id= " Textid "onblur=" Fun () ">        </div>         <!--inserting button-->        <div  class= "Btn ub ub-ac bc-text-headub-pc bc-btn umar-t"   id= "BTN" >              Press my jump page and get data          </div> 

Complete event Handling

Button event function         appcan.button (". btn",  "Ani-act",  function ()  {            appcan.window.open ({                 name: ' ShowPage ',                 data: ' Showpage.html ',                 aniid:10            });         })         //lose focus function onblur= "fun ()"          function fun ()  {             //gets the value of the current page div to Textid              var city = $ ("#textid"). attr ("value");             //alert (city);             //value is stored and set with ID cityid             appcan.locstorage.setval (' cityId ',  city);                     }


Showpage_content.html

Add div display <div id= "d1" class= "ULEV1" ></div></body> receive Data Appcan.ready (function () {//var city = App            Can.locStorage.val (' Cityid ');            var city = appcan.locStorage.getVal ("Cityid");            Alert (decodeURI (city)); $ ("#d1"). HTML (decodeURI (city) + ' Hello!                   ‘); });



Appcan Local storage for introductory learning Locstorage

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.