JavaScript tutorial:
Syntax Check

 

Up until now the only way to hunt errors in your code was to run it in a web browser, then navigate to the offending line number. You no longer need to waste your time. If you make an error, JavaScript Editor's Syntax Check:

1. Locates it in no time
2. Highlights it, and
3. Explains it for a speedy correction.

The syntax check is located in the build bar below. You can also access it via Build menu.

 

To use Syntax Check:

Click on the Syntax Check button (or press Ctrl+F8)

If you select a piece of code, Syntax Check operates only on the selected text.
If nothing is selected, Syntax Check operates on the entire text.

 

If there are no errors, Syntax Check reports "No errors found" on the status bar.

If you made an error, JavaScript Editor locates it in no time, highlights it and explains it:

This works beautifully when you are working on your JavaScript .js files. However, in many cases you will want to check "JavaScript islands" in your HTML code. Syntax Check cannot work on your web pages and always reports an error.

Of course, you could use the mouse to highlight the JavaScript code, and click on Check Syntax, but this is slow and tedious if you have many JavaScript islands on your page.

Here is the solution:

To syntax check JavaScript islands on your web page, hold Shift and click on Syntax Check (or press Shift+F8). This directs Syntax Check to look only at the code between the <script ...> .. </script> tags.

Important: Syntax Check is not limited to .js files and JavaScript used in the context of HTML pages. It works whenever you use JavaScript, including your:

- Web pages
- AJAX-powered Internet applications
- Stand-alone HTML applications (HTA), and
- Scripts (with or without JavaScript Editor extensions) automating processing on your intranet and local files.