23.04.2013 Views

javascript

javascript

javascript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

■ PREFACE<br />

xxii<br />

editor reappear. Note that the keyboard shortcut for toggling to the Console tab is Ctrl+Shift+L<br />

(Command+Shift+L). Table 1 lists vital keyboard shortcuts for Firebug.<br />

Table 1. Firebug Keyboard Shortcuts<br />

Shortcut Description Windows or Linux Mac<br />

Open Firebug F12 F12<br />

Close Firebug F12 F12<br />

Toggle to Console tab Ctrl+Shift+L Command+Shift+L<br />

Run code in command editor Ctrl+Return Command+Return<br />

If you are a fallible typist, inevitably you will mistype a code sample. Consequently, when you click<br />

Run, JavaScript will print an error in the left panel of Firebug. Those are simply JavaScript’s way of<br />

calling you a dummy.<br />

Syntax and reference errors are the most common. JavaScript names those SyntaxError and<br />

ReferenceError, respectively. So, let’s screw up in both ways now to get you off the schneid with errors.<br />

In Firebug, mistype alert as alrt in order to make a reference error, which is to say you mistyped the<br />

name of something:<br />

alrt("Don't Panic");<br />

As Figure 10 displays, JavaScript prints a ReferenceError containing the message "alrt is not<br />

defined":<br />

Figure 10. OopsJavaScript returns a ReferenceError saying "alrt is not defined".

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!