4.4 AN EXAMPLE

It is said that a language like JavaScript is best learnt by examples but first things first—A JavaScript code is written as a text file and embedded as part of HTML. We have seen earlier that HTML supports extensibility intrinsically and we show an example of how it done.

Thus the steps to run JavaScript (on the client side) are as follows.

  1. Write the program—Use any text editor, but given that a lot of IDEs support a web programming eco system, it is always better to use them. Use of an HTML editor will also help.
  2. Embed the script within an HTML (XHTML) code
  3. Invoke the HTML through a browser

Note that the above steps are not the only way to invoke a CS JavaScript. In fact, the above is just about OK for small snippets of the ...

Get Web Technology: Theory and Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.