Altering Layers Dynamically

You can alter the content of a layer dynamically to update a page in response to a visitor’s choices. You can change a layer’s content by using the Set Text of Layer behavior or by changing its innerHTML or innerText properties with the Change Property behavior.

Updating HTML Within a Layer

The Set Text of Layer behavior alters text, including HTML, within a layer element. To apply this behavior, choose Set Text Set Text of Layer from the Add Behavior (+) pop-up menu in the Behaviors panel. This behavior requires Version 4.0+ browsers. The behavior requires that at least one layer exist on the page, but the behavior cannot be applied to a layer element. Applying the behavior to a button, for example, opens the Set Text of Layer dialog box, shown in Figure 14-4.

Set Text of Layer behavior parameters

Figure 14-4. Set Text of Layer behavior parameters

In this dialog box, select the layer to modify and specify the replacement text or HTML. (You can create your text using the Document window and then copy the resulting HTML to this dialog box.) When triggered, the behavior overwrites the layer’s content with the specified HTML. You can use an onMouseOver event to trigger the change and use an onMouseOut event to restore the layer’s original contents. (There is no simple way to remember the layer’s previous contents, but you can restore them manually with a second instance of the behavior.)

Changing ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.