最初に、このスクリプトを使用して HTML コードをローカルに保存します。
queuehistory = $("#queue").html();
localStorage.setItem("queuehistory", queuehistory);
ページが読み込まれると、localstorage 項目が設定されているかどうかを検出するスクリプトを実行します。
if (localStorage.getItem("queuehistory"))
{
$("#queue").html(localStorage.getItem("queuehistory"));
}
localstorage が設定され、存在しますが、何らかの理由で html コードが $("#queue") に読み込まれません。
テスト目的で、次のコードを実行しました。
if (localStorage.getItem("queuehistory"))
{
alert(localStorage.getItem("queuehistory"));
$("#queue").html(localStorage.getItem("queuehistory"));
}
localStorage.getItem は間違いなく空ではないため、このコードが機能していないように見える理由がわかりません。ストレージ自体は機能しますが、ローカルに保存された html コードを div にロードすることはできないようです。どんな助けでも大歓迎です。