Get the whole document's html with JavaScript/JQuery

前端 未结 8 1133
无人及你
无人及你 2021-02-14 16:54

I know it\'s already discussed here, but there were no solution to get the whole document (including doctype).

$(document).html(); returns null

8条回答
  •  悲&欢浪女
    2021-02-14 17:25

    This will get you all the HTML:

    document.documentElement.outerHTML
    

    Unfortunately it does not return the doctype. But you can use document.doctype to get it and glue the two together.

提交回复
热议问题