11

I have created a IndexdDB object store in my one page (Let object store name is "ShopStore"). Now I want to open the same object store from a diffirent page. Is it possible?

My two web pages are on different domain.

Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
rohit gora
  • 113
  • 1
  • 5

1 Answers1

10

According to MDN you can't do cross domain access to an indexedDB (for security reason, you don't want that another website modify your client database):

IndexedDB follows a same-origin policy. So while you can access stored data within a domain, you cannot access data across different domains.

See also:

Community
  • 1
  • 1
Anthony Bobenrieth
  • 2,758
  • 1
  • 26
  • 38
  • 5
    **It is possible** if both domains work together. The page on a.example.com can embed an iframe on b.example.com. Both will have access to their own **separate** IndexedDB storage spaces. However, they can **communicate** via [**postMessage**](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) thus allowing them to give each other access to each others storage spaces. – Stijn de Witt Jul 23 '21 at 17:18
  • @StijndeWitt Yes, but that's more of a special case since the ('main') domain is the same, only the subdomain changes. – LuckyLuke Skywalker Jan 10 '23 at 22:37
  • 1
    Yes, it was not intended as a criticism of the answer, which simply is correct, just as a tip/suggestion for people looking for solutions. – Stijn de Witt Jan 16 '23 at 13:56