Искам да използвам localStorage.setItem
в Internet Explorer 11,
Опитах като:
<script>
localStorage.setItem("lastname", "Smith");
</script>
но в IE конзолата виждам:
SCRIPT5007: Не може да се получи свойството „setItem“ на недефинирана или нулева препратка.
Опитах и дадения отговор като:
<script>
!localStorage && (l = location, p = l.pathname.replace(/(^..)(:)/, "$1$$"), (l.href = l.protocol + "//127.0.0.1" + p));
if (typeof(Storage) != "undefined") {
// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
alert(localStorage.getItem("lastname"));
} else {
alert("Sorry, your browser does not support Web Storage...");
}
</script>
но тогава получавам:
window.webstorage.setItem('key', 'value');
, след което получавамUnable to get property 'setItem' of undefined or null reference
- person spez   schedule 05.03.2020