且构网

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

将调试消息写入Javascript控制台

更新时间:2023-12-05 13:03:34

如果你在谈论Mozilla / Firefox javascript控制台,那么在mozillazine上有一个很好的维基文档:

a:

http://kb.mozillazine.org/JavaScript_Console


看起来最简单的方法是这样做:

consoleService.logStringMessage(" Hello world!");
有没有办法将消息写入javascript控制台?




Nathan,

谢谢。我无法解决这个问题。我得到了

获取属性的权限UnnamedClass.classes

我认为该服务适用于XUL应用程序。用JavaScript写入它有没有

方式?在JavaScript控制台本身中只有''消息

'的过滤器,因此它似乎想要写入



Ion


好的,Neil在
中提供答案 http:// groups -beta.google.com/group/...ef5e734f6f2123

var message =" Hello,world!";

setTimeout(message,0 );


,因为Hello,world!作为一个方法调用是不可解析的,这会得到

记录为错误[我得到''缺失;在陈述''之前,但是对于一个单词的消息,它可能会有所不同。


Hi!
Is there a way to write messages to the javascript console? Like a
debug.write() method?
Thanks!
Ion

if you''re talking about the Mozilla/Firefox javascript console, there''s
a pretty good wiki document over at mozillazine:

http://kb.mozillazine.org/JavaScript_Console

looks like the easiest way is to do it like this:

consoleService.logStringMessage("Hello world!");
Is there a way to write messages to the javascript console?




Nathan,
Thanks. I couldn''t get that to work. I get
Permission denied to get property UnnamedClass.classes
I think that service is intended for XUL applications. Is there no
way to write to it with JavaScript? There''s a filter for ''messages
only'' in the JavaScript Console itself, so it seems to want to be
written to.
Ion


OK, Neil provides the answer in
http://groups-beta.google.com/group/...ef5e734f6f2123
var message = "Hello, world!";
setTimeout(message, 0);

since "Hello, world!" isn''t resolvable as a method call, this gets
logged as an error [I get ''Missing ; before statement'', but it would
probably be different for a single word message.]