Chr*_*ris 3 html javascript text document
我需要一个java脚本函数,它将当前加载页面的文档对象转换回它的源文本.在firefox中它是那样的:
var doc = document;
var str = (new XMLSerializer()).serializeToString(doc);
alert(str);
Run Code Online (Sandbox Code Playgroud)
但我需要一个跨浏览器解决方案.怎么做?
例如:
<html>
<body>
<script>
alert( asText(document) );
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
会弹出:
<html>
<body>
<script>
alert( asText(document) );
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
你将如何实现'asText'功能?
| 归档时间: |
|
| 查看次数: |
184 次 |
| 最近记录: |