Writing Debug Messages to the Javascript Console

I

ion

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

ion

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
 
H

Hallvord R. M. Steen

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

You got an answer for Mozilla already :)

If you debug your script in Opera you can use

opera.postError();

:)
 
C

caston

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

The best way to write to debug console is the follwoing:

throw new Error("An error occured bla-bla...")

Note, that using this construction will cause an error alert in IE
browser, and will write to javascript console in Mozilla-based
browsers.
In both cases the script flow will be interrupted after the error
arisen.
 
I

ion

caston,
Thanks! I don't want to leave the method body, is why I'm not
throwing errors.
Ion
 
I

ion

Dude! Opera rules! It's unfortunately not a supported platform for my
application. Tough to make the business case.
Thanks for your help!
 
I

ion

Thomas,
Thanks! If I caught the errors, they wouldn't be logged. The funny
thing about the 1.5 Guide's discussion of exception handling is that
they put a function 'logMyErrors' in the catch block, without giving an
implementation. All I want to do, of course, is log errors, so there
you are.
setTimeout is working great for me.
 
I

ion

Thomas,
Thanks! If I caught the errors, they wouldn't be logged. The funny
thing about the 1.5 Guide's discussion of exception handling is that
they put a function 'logMyErrors' in the catch block, without giving an
implementation. All I want to do, of course, is log messages, so there
you are.
setTimeout is working great for me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top