Section 9.7. Inserting JavaScript

9.7. Inserting JavaScript

As Chapter 11 makes clear, Dreamweaver's behaviors (prewritten JavaScript programs) let you add exciting interactive effectsmouse rollovers, pop-up windows , animated layers , and so onwith very little effort. But they can't do everything: When you, the native JavaScript speaker, need to wade into the depths of Java-Script programming yourself, you'll find two entrances within Dreamweaver.

The most straightforward approach, especially if you're already familiar with Java-Script programming, is to simply switch into Code view (Ctrl+` [Option-`]) and type away. Or, if you prefer, you can use Dreamweaver's Insert Script window to add your JavaScript code (see Figure 9-17).

To add your JavaScript code, click in either the head or body section of the page, and then choose Insert HTML Script Objects Script (alternatively, you can access this option from the Script menu on the HTML tab of the Insert bar). In the Insert Script window (Figure 9-17), choose a language from the menu: JavaScript, JavaScript1.1, JavaScript1.2, or VBScript. (The JavaScript option works with all browsers that understand JavaScript, while JavaScript 1.2 works only in 4+ version browsers. VBScript, on the other hand, works only in the Windows version of Internet Explorer.)


Tip: You can use the Insert Script command in Design view also, but to add a script to the <head> of the page, first chose View Head Content, which opens a small bar below the Document toolbar that lists all of the different tags like <title>, <script>, and <meta> that appear in the head of a page. Click here, and then follow the above recipe for inserting a script.

Dreamweaver also lets you open and work on external JavaScript files (.js files) right in Code view. The program doesn't try to interpret the file as an HTML page; it won't attempt to make any of the changes described on Section 9.1.1. But you can just use the built-in text-editing capabilities of Code view to write your JavaScript programs.


Note: JavaScript programming is no walk in the park. While it's certainly easier to learn than full-featured languages like Java or C++, it can still be challenging. If you want to get your feet wet, here's a great resource for basic tutorials and information on JavaScript: www.w3schools.com/js/.


Dreamweaver 8[c] The Missing Manual
Dreamweaver 8[c] The Missing Manual
ISBN: 596100566
EAN: N/A
Year: 2006
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net