时间:2021-07-01 10:21:17 帮助过:31人阅读
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>H5表格提交</title> <script src="appWeb.js"></script></head><body> <p id="msg"></p> <input type="text" id="input"> <input type="button" value="保存数据" onclick="saveStorage('input')"> <input type="button" value="读取数据" onclick="loadStorage('msg')"></body></html>
/** * Created by joy liu on 2015/9/22. */function saveStorage(id){ var target = document.getElementById(id); var string = target.value; sessionStorage.setItem("message",string); } function loadStorage(id){ var target = document.getElementById(id); var msg = sessionStorage.getItem("message"); target.innerHTML = msg; }
/** * Created by joy liu on 2015/9/22. *///function saveStorage(id){// var target = document.getElementById(id);// var string = target.value;// sessionStorage.setItem("message",string);//}//function loadStorage(id){// var target = document.getElementById(id);// var msg = sessionStorage.getItem("message");// target.innerHTML = msg;//}function saveStorage(id){ var target = document.getElementById(id); var string = target.value; localStorage.setItem("message",string); } function loadStorage(id){ var target = document.getElementById(id); var msg = localStorage.getItem("message"); target.innerHTML = msg; }
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>H5表格提交</title> <script src="appWeb.js"></script></head><body> <p id="msg"></p> <input type="text" id="input"> <input type="button" value="保存数据" onclick="saveStorage('input')"> <input type="button" value="读取数据" onclick="loadStorage('msg')"></body></html>
/** * Created by joy liu on 2015/9/22. */function saveStorage(id){ var target = document.getElementById(id); var string = target.value; sessionStorage.setItem("message",string); } function loadStorage(id){ var target = document.getElementById(id); var msg = sessionStorage.getItem("message"); target.innerHTML = msg; }
/** * Created by joy liu on 2015/9/22. *///function saveStorage(id){// var target = document.getElementById(id);// var string = target.value;// sessionStorage.setItem("message",string);//}//function loadStorage(id){// var target = document.getElementById(id);// var msg = sessionStorage.getItem("message");// target.innerHTML = msg;//}function saveStorage(id){ var target = document.getElementById(id); var string = target.value; localStorage.setItem("message",string); } function loadStorage(id){ var target = document.getElementById(id); var msg = localStorage.getItem("message"); target.innerHTML = msg; }
以上就是Html5的学习之旅-Html5的web Storage概述(16)的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!