我正在嘗試使用HTML5功能localStorage
。據this blog它可以使用IE8來完成,但是當我嘗試使用它,我得到一個JavaScript錯誤'localStorage is null or not an object'
IE8開箱即用支持'localStorage'
所以我的問題:可以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>
它可能有一些做的事實,你是從本地文件,而不是一個域這樣做,因爲'localStorage'依賴於域名。嘗試在線託管網頁。 – 2010-08-10 20:17:18