5,007
社区成员




<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Local storage test</title>
</head>
<body bgcolor = "F0F0F0">
<input id="000" type="text"/><input id='001' type="button" name="Sync" value="Sync" onclick="synchronize();"/>
</body>
<script type="text/javascript">
function synchronize(){
var inputElement = document.getElementById("000");
localStorage['input'] = inputElement.value;
};
function show(){
var inputElement = document.getElementById("000");
inputElement.value = localStorage['input'];
};
window.addEventListener("storage", show, true);
</script>
</html>
希望能够帮到你。