如何从页面获取HTML源代码? [英] How do I get the HTML source from the page?
本文介绍了如何从页面获取HTML源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以使用 document.body.innerHTML
是否可能?
解决方案
使用
document.documentElement.outerHTML
或
document.documentElement.innerHTML
Is there a way to access the page HTML source code using javascript?
I know that I can use document.body.innerHTML
but it contains only the code inside the body. I want to get all the page source code including head and body tags with their content, and, if it's possible, also the html tag and the doctype.
Is it possible?
解决方案
Use
document.documentElement.outerHTML
or
document.documentElement.innerHTML
这篇关于如何从页面获取HTML源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文