前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Go 语言社区】 HTML5 前端--数据保存实例

【Go 语言社区】 HTML5 前端--数据保存实例

作者头像
李海彬
发布2018-03-19 17:36:43
1.1K0
发布2018-03-19 17:36:43
举报

保存数据--->到本地s.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
        <meta charset="UTF-8">
    <!--
            作者:1528884535@qq.com
            时间:2016-01-29
            描述:数据的缓存的数据操作,应用的方式和方法
    -->
    <title>本地缓存</title>
    <script type="text/javascript">
        //  相当于与redis 去存储的数据的信息方式。主要的测试的数据更新
        var strKey = "strKey";
        var storage = window.localStorage;
        var Cookie;
        function onStart(){
            if(storage.getItem(strKey)!=null){
                alert(storage.getItem(strKey)+'localStorage');
                window.location="ww.html";
            }else if(Cookie.read(strKey)!=null){
                alert(Cookie.read(strKey)+'cookie');
            }
        }
        // 保存的数据的操作的,数据的保存到饿饿擦做的饿
        function bendihuancun() {
            alert("test data update !!! ");
            var strValue = document.getElementById("username").value;
            if (storage) {
                storage.setItem(strKey, strValue);
            } else {
                Cookie.write(strKey, strValue);
            }
            onStart();
        }
    </script>
</head>
<body >
<input type="text" id="username" value="123">
<input type="button" value="保存缓存" onclick="bendihuancun()">
</body>
</html>
获取本地数据---->
<html>
<head>
<meta charset="UTF-8">
    <script>
        document.domain = "localhost";
        function aa(){
            alert("p");
        }
    </script>
</head>
<body>
<iframe src="http://localhost/DIS/s.html" id="i">
</iframe>
<script>
    var storage = window.localStorage;
    // 后去数据,到数据本地的操作的数据;
    // 数据的保存的方式
    alert(storage.getItem("strKey")+'localStorage');
    document.getElementById('i').onload = function(){
        var d = document.getElementById('i').contentWindow;
        var a=d.a();
        console.log(a);
    };
</script>
</body>
</html>
本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2016-01-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Golang语言社区 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档