有没有办法使用 javascript 访问页面 HTML 源代码?
我知道我可以使用 document.body.innerHTML
但它只包含正文中的代码。我想获取所有页面源代码,包括 head 和 body 标签及其内容,如果可能的话,还有 html 标签和 doctype。
可能吗?
最佳答案
使用
document.documentElement.outerHTML
或
document.documentElement.innerHTML
关于javascript - 如何从页面获取 HTML 源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1367587/