Java Reference
In-Depth Information
The
form.action
property can be used to set the
action
attribute of a form, so that it
is sent to a different URL to be processed on the server:
form.action = "/alt/search"
Form Events
There are some events that are exclusive to forms.
The
focus
event occurs when the cursor is focused on that element. In the case of an input
element, this is when the cursor is placed inside the element (either by clicking on it or nav-
igating to it using the keyboard). To see an example, add the following code to scripts.js:
var input = form.elements.searchBox;
input.addEventListener('focus', function(){
alert("focused")},
↵
false);
Open search.htm in your browser and place the cursor inside the input field. You should
see an alert dialog similar to the one in the screenshot in
Figure 8.1
.
Figure 8.1. Focused!
