Behaviors > About behaviors and text |
You can't attach a behavior to plain text. Tags like p
and span
don't generate events in browsers, so there's no way to trigger an action from those tags.
However, you can attach a behavior to a link. Therefore, to attach a behavior to text, the easiest approach is to add a null link (that doesn't point to anything) to the text, then attach the behavior to the link. Note that if you do this, your text will appear as a link. (You can change the link color and remove the underlining if you really don't want it to look like a link, though site visitors may then be unaware that there's a reason to click that text.)
To attach a behavior to the selected text:
1 | In the Property inspector, enter javascript:; in the Link field. Be certain to include both the colon and the semicolon. |
Note: You can instead use a number sign (# ) in the Link field if you want. The problem with using a number sign is that when a visitor clicks the link, the browser jumps to the top of the page. Clicking the JavaScript null link has no effect at all on the page, so the JavaScript approach is generally preferable. |
|
2 | With the text still selected, open the Behaviors panel (Window > Behaviors). |
3 | Choose an action from the Actions pop-up menu, enter parameters for the action, and choose an event to trigger the action. For details, see Attaching a behavior. |
To change the appearance of linked text:
1 | Open the Code inspector (Window > Code Inspector) or the Document window's Code view. |
2 | Find the link. |
3 | In the link's a href tag, insert this attribute: style="text-decoration:none; color:black". |
This attribute setting disables underlining and sets the color of the text to black. (Of course, if the surrounding text is a different color, use that color instead of black.) | |
To change the appearance of linked text everywhere on a page or across your entire site, use CSS styles to create a new style for links. For details, see Formatting text overview. | |