Editing HTML in Dreamweaver > Inserting scripts |
You can write or insert scripts in the Code view (or Code inspector), or you can enter JavaScript and VBScript in the Design view without having to use the Code view. You can also open script files in Dreamweaver's Code view. Dreamweaver does not alter or rewrite the file. For more information, see Opening and editing non-HTML files in Dreamweaver.
To display script markers in the Document window, choose View > Visual Aids > Invisible Elements. (See also Invisible Elements preferences.)
To insert a script in code or Design view:
1 | Place the insertion point where you want the script. |
2 | Click the Script button on the Objects panel, or choose Insert > Invisible Tags > Script. |
3 | In the dialog box that appears, choose the scripting language from the Language pop-up menu. |
If you are using JavaScript and are unsure of the version, choose JavaScript rather than JavaScript1.1 or JavaScript1.2. | |
4 | Enter your script code in the Content text box. |
To link to an external script file:
1 | Follow steps 1 through 3 above. |
2 | Click OK without typing anything in the Content text box. |
3 | Select the script marker in the Design view of the Document window. |
Choose View > Visual Aids > Invisible Elements to view the marker. Make sure that scripts are selected in Invisible Elements preferences, or the script marker will not appear. For more information, see Invisible Elements preferences. | |
4 | In the Property inspector, click the folder icon to browse to and select the external script file, or type the file name in the Source box. |