I would like to create data on the user side and let javascript from another URL access it too. I am aware of the same origin policy, but I was wondering whether it is possible to create some exceptions. Or, is there any trick/feature I could use?
Best trick I know is to use iframes and postMessage
API do get access to localStorage from external domain.
This technique is quite simple:
your data domain need listen to message
event:
document.addEventListener ("message", handler, useCapture);
handler will be responsible for accessing localStorage
and posting its content to source domain
handler
function on data domain with postMessage
API
https://developer.mozilla.org/en-US/docs/DOM/window.postMessage
For security of your data you can use HTTP header X-Frame-Options ALLOW-FROM uri https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options?redirectlocale=en-US&redirectslug=The_X-FRAME-OPTIONS_response_header
Hope it will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With