zoukankan      html  css  js  c++  java
  • 16-1 WEB存储基本操作

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5</title>
    
    <script type="text/javascript">
    
    	var index = 1;
    
    	function add() {
    		localStorage.setItem('key' + index,'hello,html5');
    		index ++;	
    		alert('增加成功!');
    	}
    	
    	function update() {
    		localStorage.setItem('key1','你好,HTML5');	
    		alert('更新成功!');
    	}
    	
    	function del() {
    		localStorage.removeItem('key1');	
    		alert('删除成功!');
    	}
    	
    	function query() {
    		alert(localStorage.getItem('key1'));	
    	}
    	
    	function clearAll() {
    		alert('清除了' + localStorage.length + '个元素');
    		localStorage.clear();	
    	}
    	
    	function queryByIndex() {
    		alert('下标为0的key:' + localStorage.key(0));
    	}
    </script>
    
    </head>
    
    <body>
    
    <input type="button" value="增加" onClick="add();">
    <input type="button" value="修改" onClick="update();">
    <input type="button" value="删除" onClick="del();">
    <input type="button" value="查询" onClick="query();">
    <input type="button" value="清除全部" onClick="clearAll();">
    <input type="button" value="获得key" onClick="queryByIndex();">
    
    </body>
    </html>
    

      

  • 相关阅读:
    HDU 5671 矩阵
    HDU 5670
    UVA 11995 STL 使用
    VK Cup 2016
    字段定义
    apache用户
    apache
    使用第三方登录
    setex()
    如果客户端禁用了cookie,如何实现session
  • 原文地址:https://www.cnblogs.com/1020182600HENG/p/7077110.html
Copyright © 2011-2022 走看看