↑
Main Page
Posting messages to the JavaScript console
Posting messages to the JavaScript console (Opera 7+ only)
In Opera 7+, it’s possible to write message directly to the JavaScript console by using the
opera.postError()
method:
function test_function() {
opera.postError(“Entering function.”);
var iNumber1 = 5;
var iNumber2 = 10;
opera.postError (“Before calculation.”);
var iResult = iNumber1 + iNumber2;
opera.postError (“After calculation.”);
opera.postError (“Leaving function.”);
}
Even though the method is called
postError
, it can be used to post any message to the JavaScript console
(see Figure 14-11).
Figure 14-11
The Opera JavaScript console works in the same way as the Java console when used for debugging. The
only problem is, of course, that this code must be removed for use in other browsers.
Mozilla, Safari, and Opera all support LiveConnect; Internet Explorer does not.
430
Chapter 14
17_579088 ch14.qxd 3/28/05 11:41 AM Page 430
Free JavaScript Editor
Ajax Editor
©
→