When using my webpage ( http://localhost/mypage.html ) accessing localStorage issues a security error:
Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
It is just a simple line
res = localStorage.getItem(name);
and even
console.log(localStorage);
issues the same error.
But it is a LOCAL site, so no cross domains are used.
What goes wrong here?
This problem is related to a Chromium bug which is now fixed. See https://community.brave.com/t/html5-localstorage/100843
You can check if your current version is affected with this JSFiddle: https://jsfiddle.net/6sm54/2/
function lsTest(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.