【发布时间】:2013-04-14 16:47:37
【问题描述】:
我有一个需要像 cookie 一样进行验证的网站。但我想使用本地存储,因为它是一个移动概念。 我知道该项目是通过测试设置的,但是当它不正确时,我无法让页面重定向。
<script language="javascript">
if (localStorage.getItem('itemVerified') = 'True') {
window.location = "success.html";
}
else {
alert("You are not able to enter this site!");
window.location = "error.html";
}
</script>
【问题讨论】:
-
你有
=而不是==这是一个 JS 错误,所以我看不出这会如何重定向。 -
无论你看多少次你都看不到明显
标签: javascript html redirect local-storage