10.5 JavaScript EntitiesIn Navigator 3.0 and later, JavaScript code may appear in one additional location in a web page. This is in a JavaScript entity within the value of an attribute of an HTML tag. Recall that an HTML entity is a sequence of characters like < that represents a special character like <. A JavaScript entity is similar. It has the following syntax:
&{ JavaScript-statements }; Whenever an entity is encountered in HTML, it is replaced with its value. The value of a JavaScript entity is the value of the last JavaScript statement or expression within the entity, converted to a string. In general, entities can be used anywhere within HTML code. The JavaScript entity, however, is restricted to appear only within the value of HTML attributes. These entities allow you to, in effect, write conditional HTML. Typical usages might look like these:
<BODY BGCOLOR="&{favorite_color();};"> <INPUT TYPE="text" NAME="lastname" VALUE="&{defaults.lastname};"> |
|