Remove all content using pure JS

前端 未结 9 2388
南方客
南方客 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:55

    I believe this will still leave the doctype node hanging around, but:

    document.documentElement.remove()

    or the equivalent

    document.getElementsByTagName("html")[0].remove()

提交回复
热议问题