为什么我的HTML 5本地存储不起作用?
问题描述:
我已经创建了一个简单的html页面来测试localstorage和我的生活我无法得到它的工作,即使我的萤火虫显示localstorage存储值作为我在这里存储的是我的第一代码所谓Testhtml.html html页面为什么我的HTML 5本地存储不起作用?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>TEsthtml.html</title>
</head>
<script >
function save()
{
var passvalue = document.getElementById('entry_1').value;
localStorage.setItem('passingvalue', passvalue);
}
</script>
<body>
<form action="simple.html" method="POST">
<label for="entry_0">Type ur name</label>
<input type="text" name="entry.0.single" value="" id="entry_0">
<br>
<label for="entry_1">ur pets name
</label>
<label for="entry_1">type something</label>
<input type="text" name="entry.1.single" value="" id="entry_1">
<br>
<input type="submit" name="submit" id="submit" onClick="save()" value="Submit">
</form>
</body>
</html>
第二种形式叫simple.html代码如下
我尝试运行这段代码simple.html这是第二种形式在唯一的文本框中那里没有显示任何东西..尝试了很多不同的东西!
答
这是对8号线和9 Simple.html只是印刷错误; 'localstorage'应该是'localStorage','storedvalue'应该是'storedValue'。
你应该看看你的浏览器错误报告和开发者工具,他们会帮助你自己解决这个问题。由于使用了快速,简单和易于使用的调试工具(如果使用chrome,只需按Ctrl + Shift + J),我个人更喜欢在Google Chrome上开发。
答
simple.html的代码与testhtml.html相同。你发布了错误的代码吗?
一个简单的教程的localStorage:
哇,这是foobar !! ...非常好,它的工作只是好人tks! – JackyBoi 2011-12-24 01:22:48