2014-01-15 28 views
0

我試圖把在HTML5 localStorage的一些信息,但是,我提出與錯誤「對象#有沒有方法‘放’」以下代碼:未捕獲的錯誤:類型錯誤:對象#<Storage>沒有「放」的方法

window.localStorage.put('thing1', thing1); 
window.localStorage.put('thing2', thing2); 
window.localStorage.put('json', JSON.stringify(json)); 

在腳本的開頭,我檢查了localstorage是否存在。我並不需要指定的localStorage之前的窗口對象?

+1

嘗試['代替localStorage.setItem'](http://diveintohtml5.info/storage.html)。 – Andy

+0

謝謝,只要我貼我的問題想通了這一點。 :p – NicT

回答

0

localStorage使用localStorage.setItem而不是localStorage.put

相關問題