25 Aug Admin

o      JavaScript is an interpreted, client-side, event-based, objectoriented scripting language that you can use to add dynamic interactivity to your web pages.

o       JavaScript scripts are written in plain text, like HTML, XML, Java, PHP and just about any other modern computer code. In     this code, we will use Windows NotePad to create and edit our JavaScript code, but there are a large number of alternatives   available. NotePad is chosen to demonstrate JavaScript’s immediacy and simplicity.

o      You can use JavaScript to achieve any of the following:

    §  Create special effects with images that give the impression that a button is either highlighted or depressed whenever the mouse    pointer is hovered o ver it.

§  Validate information that users enter into your web forms

§  Open pages in new windows, and customise the appearance of those new windows.

§  Detect the capabilities of the user’s browser and alter your page’s content appropriately.

§  Create custom pages “on the fly” without the need for a server-side language like PHP.

§  And much more…

o      JavaScript is not Java, though if you come from a Java background, you will notice that both languages look similar when written. Java is a full featured and comprehensive programming language similar to C or C++, and although JavaScript can interact with Java web applications, the two should not be confused.

o      Different web browsers will run your JavaScript in different, sometimes incompatible ways. In order to work around this, it is often necessary to use JavaScript itself to detect the capabilities of the browser in which it finds itself, and alter its operation depending on the result.

o      To revisit the original definition in this chapter, note the following points:

§  Interpreted refers to the fact that JavaScript code is executed (acted on) as it is loaded into the browser. This is a change of pace from compiled languages like Java, which check your program thoroughly before running a single line of code, and can have many implications that can catch you out if you are from a non-interpreted programming background.

§  Client-side has been defined already in the previous chapter.

§  Event-based refers to JavaScript’s ability to run certain bits of code only when a specified event occurs. An event could be the page being loaded, a form being submitted, a link being clicked, or an image being pointed at by a mouse pointer.

§  Object-oriented signals that JavaScript’s power to exert control over an HTML page is based on manipulating objects within that page. If you are familiar with object-oriented programming, you will be aware of some of the power that this can bring to the coding environment.

One final note: While JavaScript is a programming language, HTML (the language of the World Wide Web) is not. HTML is a Markup Language, which means that it can be used to mark areas of a document as having special characteristics like headers, paragraphs, images, forms and so on, but it cannot perform any logical processing on its own. So while JavaScript is often written alongside HTML, the rules of one do not necessarily have any bearing on the other.