如何在调试时看到document.write的输出?

时间:2012-01-20 11:39:59

标签: javascript firebug

我经常需要在Firebug中考虑JS脚本以进行调试。通常这些脚本将使用document.write()来生成新的html内容,虽然我可以很容易地看到生成代码的代码行,但我非常希望在调试时看到生成的内容。

换句话说,我可以在调试时看到document.write的输出吗?

更新

为了避免误解,我需要澄清一点,我的意思是调试和审查其他人的脚本,例如经常使用document.write生成内容的横幅脚本。我无法控制他们使用document.write,我只需要探索输出。

我不会自己使用document.write。

2 个答案:

答案 0 :(得分:1)

写入Firebug控制台的最简单方法如下:console.log(“hello world”)

您可以根据需要传递任意数量的参数,它们将连接在一起,例如console.log(2,4,6,8,“foo”,bar)。

Intro: Firebug and Logging
API doc

答案 1 :(得分:0)

你可以复制粘贴document.write中的代码并将其作为手表粘贴到你的firebug窗口中