[英]load website from DOM string
I save my website DOM as a single string. 我将网站DOM保存为单个字符串。 I now want to read that string from the database and load the website.
我现在想从数据库中读取该字符串并加载网站。 Is there a way for javascript to parse/render a complete page from a string version of the DOM and load as the current webpage?
javascript有没有一种方法可以从DOM的字符串版本中解析/渲染完整的页面并加载为当前网页?
I am trying something like this but am not sure how to load the result as the webpage: 我正在尝试类似的方法,但不确定如何将结果加载为网页:
parser = new DOMParser();
doc = parser.parseFromString(my_dom_as_string, "text/xml");
You don't need to parse it. 您不需要解析它。 Just write it directly into the document's
outerHTML
, and the browser will parse it. 只需将其直接写入文档的
outerHTML
,浏览器就会对其进行解析。
document.documentElement.outerHTML = my_dom_as_string;
This is just the opposite of what you did to store it in your previous question. 这与您在上一个问题中存储它的相反。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.