The accessKey Property


The accessKey Property

The accessKey property enables you to specify a keyboard character that you can press with the Alt key to give an HTML element the focus (that is, make it the element that will receive keystrokes). You can see the support for this property in Table 5.4.

Table 5.4. The accessKey Property

Method

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

accessKey

             

x

x

x

                   
 

Read/Write

 

Type: String

Here's an example that gives a button the access key "b" and a text field the access key "t" :

(Listing 05-01.html on the web site)
 <HTML>      <HEAD>          <TITLE>Using Access Keys</TITLE>      </HEAD>      <BODY>          <H1>Using Access Keys</H1>          <FORM>              <INPUT TYPE="BUTTON" ID="button1" ONCLICK="alert('Hello!')" VALUE="Click graphics/ccc.gif Me!">              <INPUT TYPE="TEXT" ID="text1" VALUE="Click Me!">          </FORM>          <SCRIPT LANGUAGE="JavaScript">              <!--  document.all.button1.accessKey = "b"   document.all.text1.accessKey = "t"  // -->          </SCRIPT>      </BODY>  </HTML> 

When you open this page in the Internet Explorer, you can give the focus to the button or text field simply by using Alt + the access key. (Note that giving the button the focus clicks the button.)



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net