且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何获取HTML页面输出的实际dom作为字符串

更新时间:2021-09-02 04:26:36

您想使用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.