[英]console.log output to document instead of console
我有一个非常简单的 html 文件,它只包含以下内容:
<html>
<head>
<script defer src="./bundle_ACTUAL.js"></script>
</head>
</html>
当./bundle_ACTUAL.js
运行时,我在 Chrome 控制台中得到输出
有没有办法重定向./bundle_ACTUAL.js
输出以在文档中实际打印?
您可以覆盖console.log
的默认行为以改为写入document
:
console.log = function(e){ document.write(e) } console.log("Hello World!")
或者,只需将每次出现的console.log
替换为document.write
:
document.write("Hello World!")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.