How can I dump the entire Web DOM in its current state in Chrome?

后端 未结 4 1276
名媛妹妹
名媛妹妹 2021-01-03 18:12

I want to dump the current DOM to a file and be able to view it offline. Essentially, I have an outdated version of a page that I would like to keep around for comparison. A

4条回答
  •  难免孤独
    2021-01-03 18:31

    In Chrome Dev Tools Console, type document.documentElement.outerHTML (use the tab button for autocomplete to save keystrokes) and hit Enter to see the DOM text displayed. To copy it to your clipboard and paste it elsewhere, use copy(document.documentElement.outerHTML) instead.

    Damon's answer is also good (in Dev Tools, click Elements, right click , click Copy > Copy outerHTML), but I find the Console command easier.

提交回复
热议问题