Remove all content using pure JS

前端 未结 9 2383
南方客
南方客 2020-12-03 09:56

I\'m looking for a way to remove the entire content of a web page using pure Javascript -- no libraries.

I tried:

document.documentElement.innerHTML          


        
9条回答
  •  清歌不尽
    2020-12-03 10:57

    document.documentElement.innerHTML='';
    document.open();
    

    The Document.open() method opens a document for writing. if you dont use open method, you cant modify Document after set innerhtml to empty string

提交回复
热议问题