Reputation: 63
I have a web app with multi HTML file (example index.html, page1.html, page2.html). I don't know how the browser identifies my app as a unique web page for me can use only one indexedDB database. So, what need I do?
For details, When I load the app, index.html will be load, and when I want to open a child page (i.e page1.html), I load it by using window.location. I think that do not a right way to open child page. So, the browser can't understand my app as one unique page, and I can't use one indexedDB database for it.
Upvotes: 0
Views: 1052
Reputation: 399
The indexedDB database is local to the browser and only available to the user. IndexedDB databases follow the same rules as cookies and local storage. A database is unique to the domain it was loaded from. So for example, a database called "Foo" created at foo.com will not conflict with a database of the same name at goo.com. Not only will it not conflict, it won't be available to other domains as well. You can store data for your website knowing that another website will not be able to access it.
Upvotes: 1
Reputation: 4129
IndexedDB is limiting the database access with the same origin policy, which scopes it to the pages with same protocol :// domain : port
, so you should have access to the same databases from multiple pages under the same scope.
Upvotes: 1