久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

HTML5 Web存儲(chǔ)的localStorage和sessionStorage的使用方法【圖文說明】

 大芬油畫 2014-06-22
復(fù)制代碼
<!DOCTYPE html>
<html xmlns="http://www./1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        textarea {
            width: 300px;
            height: 300px;
        }

        .button {
            width: 100px;
        }
    </style>
</head>
<body onload="init()">
    <script type="text/javascript">
        //使用HTML5 Web存儲(chǔ)的localStorage和sessionStorage方式進(jìn)行Web頁面數(shù)據(jù)本地存儲(chǔ)。
        //頁面參考如下圖,,能將頁面上的數(shù)據(jù)進(jìn)行本地存儲(chǔ),。并能讀取存儲(chǔ)的數(shù)據(jù)顯示在頁面上。
        var t1;
        var t2;
        var oStorage;
        var oStorage;
        function init() {//初始化t1,,t2
            t1 = document.getElementById("t1");
            t2 = document.getElementById("t2");
            sStorage = window.sessionStorage;
            lStorage = window.localStorage
        }
        function saveSession() {
            sStorage.mydata = t2.value;
            t1.value += "sessionStorage保存mydata:" + t2.value + "\n";
        }
        function readSession() {
            t1.value += "sessionStorage讀取mydata:" + sStorage.mydata + "\n";
        }
        function cleanSession() {
            t1.value += "sessionStorage清除mydata:" + sStorage.mydata + "\n";
            sStorage.removeItem("mydata");
        }
        function saveStorage() {
            lStorage.mydata = t2.value;
            t1.value += "localStorage保存mydata:" + t2.value + "\n";
        }
        function readStorage() {
            t1.value += "localStorage讀取mydata:" + lStorage.mydata + "\n";
        }
        function cleanStorage() {
            t1.value += "localStorage清除mydata:" + lStorage.mydata + "\n";
            lStorage.removeItem("mydata");
        }
    </script>
    <div>
        <textarea id="t1"></textarea><br />
        <label>需要保存的數(shù)據(jù): </label>
        <input type="text" id="t2" /><br />
        <input type="button" class="button" onclick="saveSession()" name="b1" value="session保存" />
        <input type="button" class="button" onclick="readSession()" value="session讀取" />
        <input type="button" class="button" onclick="cleanSession()" value="session清除" /><br />
        <input type="button" class="button" onclick="saveStorage()" value="local保存" />
        <input type="button" class="button" onclick="readStorage()" value="local讀取" />
        <input type="button" class="button" onclick="cleanStorage()" value="local清除" />
    </div>
</body>
</html>
復(fù)制代碼

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多