简体   繁体   中英

Store/Load a modified HTML5 Page from localStorage

Is it possible to store a (with JS) modified HTML5 Page to localStorage and load it at the next visit of this Page?

I try to set somewhere on the Page a Tag by my Chrome Extension and load it again.

Yup.

You can even run this on this very page.

1) Modify the page.

document.querySelector('#hlogo').innerHTML = '<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Siamese_Cat_Cross-Eyed.jpg/1280px-Siamese_Cat_Cross-Eyed.jpg">';

2) Save the page.

localStorage['thispage'] = document.querySelector('html').innerHTML;

3) Refresh the page.

4) Restore it from localStorage

document.querySelector('html').innerHTML = localStorage['thispage'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM