localStorage access from local file
When you are opening the files locally, i.e. using the file://
protocol, as of now the browsers can not determine what is "same domain" so every file is considered a separate domain. Thus you can not use localStorage
when you're opening the files.
Here is some more information on the problem in FireFox: https://bugzilla.mozilla.org/show_bug.cgi?id=507361 . Personally I couldn't find much about Safari on this topic.
You can also look over this: Javascript/HTML Storage Options Under File Protocol (file://) . It might be helpful in your situation.
Accessing localStorage from js file cached by ServiceWorker
That's fine, yes.
You can think about the service worker as proxying the network requests that are made for logic.js
and any other resources/subresources. Once the network request is done, the service worker is effectively "out of the picture" (the thread that it's running in will actually stop unless there are active events).
The fact that the service worker was involved in loading logic.js
does not prevent you from using local storage or doing anything else from within logic.js
.
How do I allow my local web page access to LocalStorage in Brave Browser?
There is 2 ways you can achieve this. Probably also depends how you run your project. I use VS Code and when I run my projects in Brave I got that error. My files were just in a dev directory not in the wwwroot directory.
First option (recommended in my opinion)
- Go to: Setting->Additional Settings->Privacy and Security->Site Settings->Cookies
- In the "Allow" section add: "localhost" and "127.0.0.1"
Second option (not recommended, as you also stated you don't want to do this)
- Go to: Settings->Shields->Cookie Control
- Select "Allow all cookies"
Hope this helps
Related Topics
Asynchronous Operations in Constructor
Creating an Iframe with Given HTML Dynamically
Export JavaScript Data to CSV File Without Server Interaction
Good Ways to Improve Jquery Selector Performance
Rails 4 Turbo-Link Prevents Jquery Scripts from Working
Adding a New Array Element to a JSON Object
Get the Content (Text) of an Url After JavaScript Has Run with PHP
How to Keep the Menu State on Page Reload
How to Move Table Row in Jquery
Removing Page Title and Date When Printing Web Page (With CSS)
Is It Ok to Add Your Own Attributes to HTML Elements
Convert Td Columns into Tr Rows
Location.Host VS Location.Hostname and Cross-Browser Compatibility
How to Retrieve If the Popstate Event Comes from Back or Forward Actions with the HTML5 Pushstate
How to Print Only a Selected HTML Element
Get Caret (Cursor) Position in Contenteditable Area Containing HTML Content