GTS*_*Joe 5 html javascript dom
我正在创建一个 HTML 文档对象:
let newHTMLDocument = document.implementation.createHTMLDocument();
let html = `<!DOCTYPE html>
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>`;
newHTMLDocument.open();
newHTMLDocument.write( html );
newHTMLDocument.close();
console.log( String(newHTMLDocument) ); // [object HTMLDocument]Run Code Online (Sandbox Code Playgroud)
如何将 newHTMLDocument 转换为包含所有 HTML 代码(包括 doctype 和 html 标记)的字符串,而不是“[object HTMLDocument]”?