3

My website www.abc.com

I am using iframe in www.abc.com with <iframe src="www.xyz.com"></iframe>

I am facing the below issue

Issue :

Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

How to solve the issue with only using source code (Angularjs(V 1.X), Javascript, jQuery, HTML), without touching browser settings manually.

Is there any way to change browser settings(set allow cookies) via source code or server side settings?

www.abc.com , www.xyz.com both website localstorage used indivudually, I am not accessing localstorage from one website to other.

When i open the iframe page i am facing the issue "Failed to read the 'localStorage' property from 'Window': Access is denied for this document."

raj
  • 356
  • 1
  • 5
  • 20
  • Does this answer your question? [Cross domain iframe issue](https://stackoverflow.com/questions/9393532/cross-domain-iframe-issue) – Ivar Oct 20 '21 at 07:17
  • Are you trying to access the localStorage from site abc in the website in the iframe (xyz)? – Pierre Arlaud Oct 20 '21 at 13:30
  • I am using localStorage here "www.xyz.com", not trying to access "www.abc.com" – raj Oct 25 '21 at 14:13
  • https://stackoverflow.com/questions/9393532/cross-domain-iframe-issue This one not helped me. – raj Oct 25 '21 at 14:15

2 Answers2

1

I had the same question, you maybe change your chrome cookie setting

this is the document link

ZoeyZhou
  • 11
  • 1
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 16 '22 at 16:32
-3

The following snippet accesses the current domain's local Storage object and adds a data item to it using Storage.setItem().

 localStorage.setItem('myCat', 'Tom');

The syntax for reading the localStorage item is as follows:

const cat = localStorage.getItem('myCat');

Kind refer to the following documentation

Shaheer Wasti
  • 65
  • 1
  • 10