0

I am working on Live Editor and use a HTML5 localstorage to store some important data,on my Main Page,

And I have an Iframe on my Main Page that is working on same domain which is used to show the result of editor, Here the problem is, whenever i write the JS code :

Like :

localStorage.clear();

To my editor and run it on my Iframe then it also clear my localStorage of Main Page.

How i Correct this problem ?

I am sending my code to iframe by using string,

iframe.contentWindow.document.head.appendChild(Script);

Script contains a script tag with the User Code and it will run only inside iframe! But Why my localStorage.clear(); also clear Stored data of Main Page ?

Answer Will really appreciated !!

ashbuilds
  • 1,361
  • 11
  • 29

1 Answers1

0

It's more or less anwsered here:

In HTML5, is the localStorage object isolated per page/domain?

localStorage is per domain.

Community
  • 1
  • 1
anddoutoi
  • 9,289
  • 3
  • 27
  • 28
  • you right,but is there any solution without using key,to prevent my localstorage of main page ? – ashbuilds Mar 06 '14 at 16:07
  • 1
    Nope. clear() clears (with the power of lemon). You could ofc use a subdomain or other domain completly. But then you have other problems I guess. – anddoutoi Mar 06 '14 at 16:09