婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > html5超簡(jiǎn)單的localStorage實(shí)現(xiàn)記住密碼的功能實(shí)現(xiàn)

html5超簡(jiǎn)單的localStorage實(shí)現(xiàn)記住密碼的功能實(shí)現(xiàn)

熱門標(biāo)簽:黃島區(qū)地圖標(biāo)注 當(dāng)涂高德地圖標(biāo)注 江蘇智能電銷機(jī)器人哪家好 四川點(diǎn)撥外呼系統(tǒng) 南寧點(diǎn)撥外呼系統(tǒng)哪家公司做的好 云南大理400電話申請(qǐng)官方 電銷機(jī)器人電話用什么卡 成都智能外呼系統(tǒng)平臺(tái) 鎮(zhèn)江智能外呼系統(tǒng)有效果嗎

HTML5 提供了兩種在客戶端存儲(chǔ)數(shù)據(jù)的新方法:

  • localStorage - 沒有時(shí)間限制的數(shù)據(jù)存儲(chǔ)
  • sessionStorage - 針對(duì)一個(gè) session 的數(shù)據(jù)存儲(chǔ)

之前,這些都是由 cookie 完成的。但是 cookie 不適合大量數(shù)據(jù)的存儲(chǔ),因?yàn)樗鼈冇擅總€(gè)對(duì)服務(wù)器的請(qǐng)求來傳遞,這使得 cookie 速度很慢而且效率也不高。

在 HTML5 中,數(shù)據(jù)不是由每個(gè)服務(wù)器請(qǐng)求傳遞的,而是只有在請(qǐng)求時(shí)使用數(shù)據(jù)。它使在不影響網(wǎng)站性能的情況下存儲(chǔ)大量數(shù)據(jù)成為可能。

對(duì)于不同的網(wǎng)站,數(shù)據(jù)存儲(chǔ)于不同的區(qū)域,并且一個(gè)網(wǎng)站只能訪問其自身的數(shù)據(jù)。

HTML5 使用 JavaScript 來存儲(chǔ)和訪問數(shù)據(jù)。

localStorage 方法存儲(chǔ)的數(shù)據(jù)沒有時(shí)間限制。第二天、第二周或下一年之后,數(shù)據(jù)依然可用。

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
</head>
<style type="text/css">
    form{
        width: 300px;
        padding: 10px 0px 20px 30px;
        height:auto;
        border-radius: 6px;
        border-left:8px solid #19a049;
        background:#eee;
        margin:100px auto;
    }
    #user,#pass{
        padding: 8px;
        outline: none;
        background: transparent;
        border:1px solid #999;
        margin-top: 5px;
    }
    #sub{
        padding: 6px;
        outline: none;
        border:none;
        background: #19a049;
        color:#fff;
        width: 150px;
        border-radius: 6px;
        cursor: pointer;
    }
</style>
<body>
    <form action="" method="" onsubmit="return loginBtn_click();">
        <h3>Log in</h3>
        <input type="text" name="user" placeholder="user" id="user">
        <input type="password" name="pass" placeholder="password" id="pass">
        <input type="checkbox" id="remember" checked><br/><br/>
        <input type="submit" id="sub">
    </form>
</body>
<script type="text/javascript">
    $(document).ready(function(){

        var strName = localStorage.getItem('keyName');
        var strPass = localStorage.getItem('keyPass');
        if(strName){
            $('#user').val(strName);
        }if(strPass){
            $('#pass').val(strPass);
        }

    });

    function loginBtn_click(){
            var strName = $('#user').val();
            var strPass = $('#pass').val();
            localStorage.setItem('keyName',strName);
            if($('#remember').is(':checked')){
                localStorage.setItem('keyPass',strPass);
            }else{
                localStorage.removeItem('keyPass');
            }
        }
</script>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:淮安 酒泉 十堰 廣西 佳木斯 咸寧 西寧 南京

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《html5超簡(jiǎn)單的localStorage實(shí)現(xiàn)記住密碼的功能實(shí)現(xiàn)》,本文關(guān)鍵詞  html5,超,簡(jiǎn)單,的,localStorage,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《html5超簡(jiǎn)單的localStorage實(shí)現(xiàn)記住密碼的功能實(shí)現(xiàn)》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于html5超簡(jiǎn)單的localStorage實(shí)現(xiàn)記住密碼的功能實(shí)現(xiàn)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 四会市| 会泽县| 黄石市| 叶城县| 揭东县| 全州县| 阿勒泰市| 上饶县| 东平县| 平舆县| 从江县| 马尔康县| 滨州市| 灌云县| 莱芜市| 庆城县| 博客| 石屏县| 阳东县| 阜宁县| 山西省| 镇赉县| 平湖市| 大兴区| 泉州市| 德清县| 贵南县| 大新县| 上饶市| 沧州市| 深圳市| 饶平县| 漳平市| 沙河市| 泸定县| 山西省| 安庆市| 天水市| 北海市| 嘉黎县| 乌什县|