<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="assets/js/jquery-1.8.3.min.js"></script>
<title>本地缓存</title>
<script type="text/javascript">
function onStart(){
if (sessionStorage.weixinname) {
document.getElementById("username").value = sessionStorage.weixinname;
}
}
function bendihuancun(){
sessionStorage.weixinname = document.getElementById("username").value;
window.location.href="NewFile1.jsp";
}
</script>
</head>
<body οnlοad="onStart()">
<input type="text" id="username">
<input type="button" value="bendi" οnclick="bendihuancun()">
</body>
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="assets/js/jquery-1.8.3.min.js"></script>
<title>本地缓存</title>
<script type="text/javascript">
function onStart(){
if (sessionStorage.weixinname) {
document.getElementById("username").value = sessionStorage.weixinname;
}
}
function bendihuancun(){
sessionStorage.weixinname = document.getElementById("username").value;
window.location.href="NewFile1.jsp";
}
</script>
</head>
<body οnlοad="onStart()">
<input type="text" id="username">
<input type="button" value="bendi" οnclick="bendihuancun()">
</body>
</html>
当进行页面重定向后再次跳转到这个页面时你text内输入的东西会依然存在,这只是一个临时存储,当你关闭本页浏览器后缓存清除