Javascript 修复损坏的html

Javascript 修复损坏的html,javascript,html,Javascript,Html,我有一个网页,当我停止使用window.stop()时,我想停止所有请求并替换我的自定义html;只有下面的html被加载,我想用我的自定义html替换它 <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Test</t

我有一个网页,当我停止使用window.stop()时,我想停止所有请求并替换我的自定义html;只有下面的html被加载,我想用我的自定义html替换它

<html xmlns="http://www.w3.org/1999/xhtml">
   <head id="Head1">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <title>Test</title>
       <link type="text/css" rel="stylesheet" href="../BaseMasterPage/styles/jquery.autocomplete.css">

   </head>
</html>

注意:我正在使用tampermonkey修改一个网站。

您是否尝试过设置
document.body=body
?尝试使用var body=document.createElement(“body”);body.innerHTML=“hello world

”;document.querySelector(“html”).appendChild(body);为什么document.write在stop()之后不工作?您是否尝试过设置
document.body=body
?尝试使用var body=document.createElement(“body”);body.innerHTML=“hello world

”;document.querySelector(“html”).appendChild(body);为什么document.write在stop()之后不工作?
var htmlc ='<html><head><script language="Javascript">function Hi() {alert("Goodbye World");}</script></head><body onload="Hi();">New Content</body></html>';

        document.open();
        document.write(htmlc);
        document.close();
  var body = document.createElement("body");
    body.innerHTML = "<p>hello world</p>";
    document.firstChild.appendChild(body);
Uncaught DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.