When a page loads, the behavior sets the focus to the specified field. Without this behavior, browsers usually set initial focus to the "URL" field in the toolbar.
If a field is specified, focus is given to that field. Otherwise, focus is set to the first field in the page's tab order.
<hx:inputHelperSetFocus>
Use with <body> only.
hX_5.addBehavior("#body", "onload", new hX_5.JSFBehaviorFocus(attributes)); where
attributes |
Comma separated list of attributes where each attribute is a quoted string consisting of the attribute name and value separated by a colon, for example "label:MyLabel". |
Note the use of the special ID #body.
Event |
Description |
---|---|
onload |
The behavior can only be used to specify the initial focus in the page. |
Attribute name |
Description |
---|---|
focus-id |
The ID of the field given focus. If omitted, focus is given to the first field in the page's tab order. |
select |
If True, the field's contents are selected (if selection is possible). Otherwise, the field's content is left unselected unless the browser enforces selection when a field is given focus. |
Runs after any other handlers provided for the event.
Does not stop the event.
API call |
Description |
---|---|
object = setAttribute(attribute) |
Sets an attribute or changes its value (if it was set previously). |
string = getAttribute(attribute-name) |
Retrieves the current value of an attribute. |
Set focus to the first field in the page's tab order. Select the contents.
hX.addBehavior("#body", "onload", new hX.JSFBehaviorFocus("select"));
Set focus to the specified field.
hX.addBehavior("#body", "onload", new hX.JSFBehaviorFocus("focus-id:form1:menu2"));