从localStorage存储/加载已修改的HTML5页面 [英] Store/Load a modified HTML5 Page from localStorage
本文介绍了从localStorage存储/加载已修改的HTML5页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能将(使用JS)修改后的HTML5页面存储到localStorage并在本页下次访问时加载它?
我尝试设置某处
解决方案
是的。
你甚至可以在这个页面上运行它。
1)修改页面。 p $ p> 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)保存该页面。
localStorage ['thispage'] = document.querySelector('html')。innerHTML;
<3>刷新页面。
4)从localStorage恢复它
document.querySelector('html')。innerHTML = localStorage ['thispage'];
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'];
这篇关于从localStorage存储/加载已修改的HTML5页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文