我正在尝试使用HTML5功能localStorage.根据这篇博客,它可以使用IE8完成,但是当我尝试使用它时,我收到一个javascript错误'localStorage is null or not an object'
所以我的问题:localStorage开箱即用的IE8可以使用吗?这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>IE8 - DOM Storage</title>
<script type="text/javascript">
function Save() {
localStorage.setItem('key','value');
}
</script>
</head>
<body>
<button onclick="Save();">
Save
</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我的应用程序几乎在所有浏览器中运行,但是当我使用ie8预期标识符发生时.
$scope.delete = function (index) {
$scope.recipelists.splice(index, 1);
localStorage.setItem('markedRecipes', JSON.stringify($scope.recipelists))
if ($scope.recipelists == 0) {
$modalInstance.dismiss('cancel');
}
}
Run Code Online (Sandbox Code Playgroud)
这是ie8的控制台在错误显示时指示我的地方.
我不知道这有什么问题.
谢谢!