GREATINTERNETPROOFING.COM

photography shopping cart - www.greatinternetproofing.com

Menu


fields, enter a number for their station ID, and even enter an email address into a text box that requires an email address. Furthermore,


you might want to add functionality that forces the browser to check for a specific plug-in like Flash and have the browser react accordingly. All this and much more is possible with JavaScript. As is true with HTML and CSS, you aren't required to know JavaScript when working in Dreamweaver. And as do HTML and CSS, Dreamweaver writes all the JavaScript to make these actions happen in the form of behaviors. Exposed as canned JavaScript snippets of code and available in the Behaviors panel, behaviors available in Dreamweaver are ideal for real-world applications where time is of the essence and your JavaScript writing skills are limited. This chapter aims at preparing you to work with the final building block to client-side web development, JavaScript behaviors. To begin, you'll need to download the support files online. As you have done for the rest of the chapters in this book, you can work with the examples in this chapter by downloading the files from www.dreamweaverunleashed.com. You'll want to save the files for Chapter 10 in an easy-to-find location. I'll place mine in C:\Dorknozzle\Chapter10.           An Introduction to Behaviors To understand how behaviors in Dreamweaver work is to understand the fundamentals of JavaScript. Similar to CSS, JavaScript code is written within the <head> tag of your web page. Unlike CSS, which is written within a <style> declaration block, JavaScript is written within a <script> declaration block complete with the language attribute defining the language to be written in the script. A typical declaration block for a page might look something like this:   <html> <head> <title>Sample JavaScript</title> <script language="JavaScript"> </script> </head> <body> </body> </html>   As you can see from the sample, the code declaration block acts as a container for the logic within the web page. Of course, this code sample is merely a shell of the functionality. To make the page a bit more interactive, we would add three components to this example: an object, an event, and a function that represents the action we want performed. The final product might resemble something like this:   <html> <head> <title>Sample JavaScript</title> <script language="JavaScript"> function showMessage() { window.alert("Hello"); } </script>