我如何获取HTML页面输出的实际dom作为字符串 [英] how do i get the actual dom of an html page output as a string

查看:137
本文介绍了我如何获取HTML页面输出的实际dom作为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在无法在系统上重现的远程计算机上调试问题。页面加载后,将通过javascript调用动态添加dom对象。我需要获取页面的输出,因为它是由浏览器呈现的。查看源仅检索页面的原始内容。在内容呈现完毕并进行任何DOM更改后,我需要内容。

I am trying to debug a problem at a remote computer that I am unable to reproduce on my system. Once the page loads, dom objects are added dynamically via javascript calls. I need to get the output of the page as it is rendered by the browser. View source only retrieves the pages original content. I need the content AFTER it has finished being rendered and any DOM changes were made.

更具体地说,在Chrome中使用开发人员工具时,元素标签显示我有兴趣从用户那里收到的实际代码。

To be more specific, when using the developer tools in Chrome, the "elements" tab shows the actual code I am interested in receiving from the user.

有什么想法吗?

推荐答案

您想使用javacsript实现它吗?然后尝试以下操作:

You want to achieve it using javacsript? Then try this:

alert(document.documentElement.innerHTML);

如果使用浏览器-您应该安装firebug扩展名,它会在浏览器看到的情况下显示DOM。但是保存的实际dom可能不起作用,因为所有动态附加的元素事件处理程序都会丢失。

If with a browser - you should install firebug extension, it shows the DOM as a browser sees it. But the saved actual dom may not work, because all dynamically attached element event handlers would be lost.

这篇关于我如何获取HTML页面输出的实际dom作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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