Chapter 23. JavaScript

So far you have learned about server-side programming. With server-side programming all of the processing takes place on the server and has to be sent over the Internet to the browser; the browser is the client. With JavaScript, it is possible to do client-side programming to take advantage of the processing power of the computer that is running the browser. In this lesson I teach you how to use JavaScript and introduce you to jQuery, one of the most popular JavaScript libraries.

JavaScript was developed by Netscape back in 1995. Due to its name, many people assume that JavaScript is related to Java; however, it has nothing to do with Java. It is a dynamic, object-oriented language that has many similarities to C#, such as case-sensitivity and syntax.

HOW TO USE JAVASCRIPT

This is a sample of an HTML page that includes JavaScript:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Hello World</title>
</head>
<body>
    <input id="submitbutton" type="submit" value="Click Me" onclick="Hello()"
        />

    <script type="text/javascript">
        // Displays Hello World in a popup box.
        function Hello() {
            alert("Hello World");
        }
    </script>

</body>
</html>

Figure 23-1 shows the page that is rendered by using the preceding code.

When the Click Me button in Figure 23-1 is clicked, the popup box shown in Figure 23-2 is rendered.

Figure 23.1. FIGURE 23-1

Figure 23.2. FIGURE ...

Get ASP.NET 4 24-Hour Trainer 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.