使用JavaScript/JQuery获取整个文档的html [英] Get the whole document's html with JavaScript/JQuery

查看:300
本文介绍了使用JavaScript/JQuery获取整个文档的html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这里已经讨论过了,但是没有解决方案来获取整个文档(包括doctype).

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

$(document).html();返回null ...

推荐答案

这将为您提供所有HTML:

This will get you all the HTML:

document.documentElement.outerHTML

很遗憾,它不返回doctype.但是您可以使用document.doctype进行获取,并将两者粘合在一起.

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

这篇关于使用JavaScript/JQuery获取整个文档的html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆