O'Reilly logo

Dreamweaver in a Nutshell by Bruce A. Epstein, Heather Williamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JavaScript

Dreamweaver works with JavaScript in a variety of ways. In addition to using JavaScript behaviors, you can link to scripts in external .js files, edit .js files directly, and debug JavaScript code.

Adding Scripts to Documents

When you apply behaviors using the Behaviors panel, Dreamweaver adds the JavaScript to the <script> tag within the <head> tag. (All scripts used throughout a site are listed in the Scripts category of the Assets panel.) If you apply the same behavior twice within the same document, Dreamweaver is smart enough not to duplicate the JavaScript code within the <script> tag. You can even modify the JavaScript functions by hand in Code view, provided you don’t change a function’s name, Dreamweaver won’t overwrite your changes even if you reapply the same behavior.

The Insert Script dialog box

The Insert Invisible Tags Scripts menu command opens the Insert Script dialog box where you can enter scripts by hand. The Script button in the Objects panel’s Invisibles category opens the same dialog box. See Section 2.7.3 in Chapter 2 for more details.

Call JavaScript behavior

The Call JavaScript behavior is used to execute a line of JavaScript code. That line can include a call to a custom function or a built-in function such as window.close(). Figure 12-4 shows the exceedingly simple dialog box that lets you enter your parameters for the Call JavaScript behavior.

Figure 12-4. The Call JavaScript parameters dialog box

Other behaviors have more complex parameters, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required