Click here to Skip to main content
15,881,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi there. Working on an extension where DOM trees has to be created on the fly. For example, I have a list of icons, all in #grid2 and upon clicking an icon, the corresponding content is expected to display in #grid1 .

But managing state across icons’ DOM contents and sub-contents is a struggle. For example, a user leaves Icon A after reaching its second view (sub content/another layer in the DOM) to click Icon C before returning back to Icon A. I want them to able to continue from Icon A’s second view where they initially left in that session. I tried to persist DOM state with localStorage but it only works for strings.

Here is the code.

What I have tried:

localStorage.setItem('retainView', grid1.innerHTML);
Posted
Updated 16-Oct-22 18:48pm
v2
Comments
Richard Deeming 17-Oct-22 5:30am    
The innerHTML property is a string. What precisely is the problem?
Dzhud07 2-Jan-23 9:47am    
Hi. Thanks for your response. It's not returning elements like I want. I'll have to admit that the localStorage example I gave doesn't reflect exactly what I'm referring to. The link in the original question perfectly shows what the problem is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900