Accessibility

TechNote (Archived)

Using behaviors in templates

A Web site may have several files all based on a common template, but some of the files need behaviors (such as button rollovers or pop-up windows) in them, and others don't. Because theHEADin template files is not editable, Dreamweaver does not allow behaviors to be added to files based on a template.

Note:This TechNote is intended for use with Dreamweaver 2 templates. If using Dreamweaver 3 or Dreamweaver 4 templates, please see Adding Behaviors to templates and documents created from templates (TechNote 14797).

While theHEADitself is not editable, it is possible to add an editableSCRIPTtag to theHEADof a template file. When a behavior is added to a file to which the template is applied, Dreamweaver automatically inserts the behavior function into this editable area.

Note:Because theHEADwasn't originally designed to be editable, Dreamweaver may try to strip out the contents of the last editable region in theHEAD. To work around this problem, just add an extra, "sacrificial" editable region.

To add an editableSCRIPTtag to theHEADof a template:

1 Open the template (.dwt) file in Dreamweaver.
2 Choose Window > HTML to open the HTML inspector, and then position the cursor just before the closingHEADtag (</head>).
3 Type the following code:
 
 <mm:editable><SCRIPT></SCRIPT></mm:editable><mm:editable><!-- Dreamweaver will delete this comment. --></mm:editable> 
4 Save the file. When the Dreamweaver dialog asks if it should update files that use
this template, click Yes.

Behaviors can now be added to files that are based on the template, and behaviors can also be added to the template file (the .dwt file) itself without worrying that the function associated with the behavior will be deleted.

Note:If applying a template to a file that already exists, do not add thisSCRIPTcode to the template until the template has already been applied. Once the template has been applied to the document, then edit the template to include this SCRIPT code and update the files. Applying a template containing thisSCRIPTto a document containing content will force all of the existing content to be assigned to this editable region in theHEAD.



AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support

Document Details

ID:tn_13691

Products Affected:

dreamweaver