简体   繁体   English

从localStorage存储/加载修改后的HTML5页面

[英]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? 是否可以将(使用JS)修改后的HTML5页面存储到localStorage并在下次访问此页面时加载它?

I try to set somewhere on the Page a Tag by my Chrome Extension and load it again. 我尝试通过Chrome扩展程序在页面上设置标记并再次加载。

Yup. 对。

You can even run this on this very page. 你甚至可以在这个页面上运行它。

1) Modify the page. 1)修改页面。

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. 2)保存页面。

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

3) Refresh the page. 3)刷新页面。

4) Restore it from localStorage 4)从localStorage恢复它

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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