15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Generic Objects<br />

Properties<br />

accessKey<br />

Chapter 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓<br />

Example<br />

When you load the script in Listing 15-1, adjust the height of the browser window<br />

so that you can see nothing below the second dividing rule. Enter any character<br />

into the Settings portion of the page and press Enter. (The Enter key may cause<br />

your computer to beep.) Then hold down the Alt (Windows) or Ctrl (Mac) key while<br />

pressing the same keyboard key. The element from below the second divider<br />

should come into view.<br />

Listing 15-1: Controlling the accessKey Property<br />

<br />

<br />

accessKey Property<br />

<br />

function assignKey(type, elem) {<br />

if (window.event.keyCode == 13) {<br />

switch (type) {<br />

case “button”:<br />

document.forms[“output”].access1.accessKey = elem.value<br />

break<br />

case “text”:<br />

document.forms[“output”].access2.accessKey = elem.value<br />

break<br />

case “table”:<br />

document.all.myTable.accessKey = elem.value<br />

}<br />

return false<br />

}<br />

}<br />

<br />

<br />

<br />

accessKey Property Lab<br />

<br />

Settings:<br />

Continued<br />

3<br />

elementObject.accessKey

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!