Chapter 15. Text Behaviors

This chapter covers Dreamweaver’s text behaviors, which can specify text for layers, frames, text fields, alert boxes, and the browser status bar.

Altering Text

Dreamweaver’s text behaviors, such as the Set Text of Layer behavior covered in the previous chapter, can update plain text (and sometimes HTML code) in the target element.

Generating Dynamic Text via JavaScript

When setting text using Dreamweaver’s Set Text behaviors, text contained within curly braces is treated as a JavaScript expression.

For example, the following text would display today’s date:

Today's date is {new Date(  )}

To display a document’s modification date, you can use Dreamweaver’s Insert Date command (discussed in Chapter 2) or JavaScript of the form:

Document last modified on {document.lastModified}

To display an actual curly brace in the text, precede it with a backslash, such as in:

This is how you display a curly brace \{

Altering Text and HTML in Frames

Use the Set Text of Frame behavior to update the text, including HTML, in a frame without reloading the entire document. Naturally, to use this behavior, the document must contain one or more frames (Chapter 4 explains how to add frames). To apply this behavior, choose Set Text Set Text of Frame from the Add Behavior (+) pop-up menu in the Behaviors panel. This behavior is typically applied to an image acting as a button. Applying the behavior opens the Set Text of Frame dialog box, shown in Figure 15-1.

Figure 15-1. Set Text ...

Get Dreamweaver in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.