in black and white
Main menu
Home About us Share a book
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

Javascript for dummies. Quick Reference - Vander

Vander Javascript for dummies. Quick Reference - Wiley Publishing, 2002. - 115 p.
Download (direct link): javascriptquickreference2002.pdf
Previous << 1 .. 46 47 48 49 50 51 < 52 > 53 54 55 56 57 58 .. 72 >> Next

<INPUT TYPE="checkbox" NAME="firstBook"
VALUE=''fi rstBook" onClick="if (this.checked) { sendThankYouLetter() }">
Is this your first ...For Dummies book purchase? link
<A H REF=""
onCli ck="thi s.href=pi ckURLBasedOnUserPreferences()" > You'll want to see this!
Which is your favorite vacation destination?
<IN P UT TYPE="radio" NAME="vacationSelection" VALUE=”beach" onCli сk="di splay Page('beachfront property' ) ">
The beach
<IN PUT TYPE="radio" NAME=”vacationSelection" VALUE="mountain" on Cl i ck=''di spl ayPage( ' mountai n cabi ns ' ) ">
The mountains <IN PUT TYPE="radio" NAME="vacationSelection" VALUE="ci ty"
onClick=”displayPage('posh hotels')"> Anywhere I can get room service
CINPUT TYPE="reset" NAME="reset" VALUE="C1ear form" onCli сk=”resetCalculatedTotals()”>
Netscape Navigator running on a Windows platform doesn’t care if you return a value of fal se for areset onClick event handler; it goes ahead and resets the form no matter what happens when a user clicks the reset button — even if you think you stopped the reset from happening in the onClick event handling code.
<IN PUT TYPE="submi t" NAME="submi t" VALUE="Submit form"
onClick="checkConsi stency()">
You can use the onError event handler to trigger the execution of some JavaScript code every time an error occurs while a user is attempting to load either an image (the Image object) or a document (the wi ndow object). A good use for the onError event handler is to invoke a custom function designed to examine the error, figure out what caused it, and then suggest solutions.
onError="event handler text"
You can use the о n E г г о r event handler with both the Image and wi ndow objects. The following code shows examples of each.
<IMG NAME="noSuchAnimal" SRC="dummy.gif" onError="alertCdocument.myForm.noSuchAnimal .name +
' could not be loaded')">
wi ndow.onerror=myOnErrorHandler
function myOnErrorHandler(message, url , lineNumber) {
return true
Don’t want your users to see any JavaScript-generated errors for a particular document? You can head them all off at the pass before they’re displayed to the user by setting the onError event handler equal to null, like this:
window.onerror = null
onFocus is an event handler associated with the frame, select, text, texta rea, and wi ndow objects. Think of this event handler as the anti-on В1 u r; instead of responding when an object loses
150 on Focus
focus, onFocus is invoked when an object gains focus. (An object gains focus when a user tabs to, or clicks on, the object.)
You might expect that selecting text inatextortextarea element would trigger the onFocus event handler because selecting text implies clicking on that text, which should (in turn) give focus to that element. Well, that conclusion is logical, but it’s incorrect. JavaScript considers text selection within a field a special case; instead of calling the onFocus event handler, JavaScript invokes the on Sel ect event handler.
See also “onSelect,” later in this part.
Guess what happens if the code that’s invoked by the onFocus event handler contains a call to a dialog box ? Well, after the element gets focus, the dialog box pops up. The user clicks OK or Cancel or whatever. Focus returns to the element. The dialog box pops up. The user clicks OK or Cancel or whatever. Focus returns to the element. The dialog box pops up.. .. Can you say endless loop? Please, don’t try this at home!
onFocus=” event handler text"
You can use the onFocus event handler with the frame, select, text, textarea, and wi ndow objects. The following sections contain examples of each.
The first section of code below defines a frame named f ramel whose source is the HTML file f ramconl. html; the second section shows how the onFocus event handler is implemented for
<FRAMESET ROWS="50%,50%" C0LS="40%, 60Г onLoad="di splay() ">
<FRAME SRO"framconl.html" NAME="f ramel">
<FRAME SRC="framcon2.html" NAME="frame2">
The following code fragment is found in the file called framconl.html referenced in the preceding code.
<B0DY BGC0L0R="1i ghtgrey"
onBlur="document.bgColor='black'" onFocus="document.bgColor='whi te'”>
on Load 1
Product: <SELECT NAME="productSel ection" SIZE=1 onFocus="validateDependentFields()">
<0PTION VALUE="shi rt"> t-shirt <0PTI0N VALUE="mug"> mug <0PTI0N VALUE="rag"> monogrammed dishrag </SELECT>
Last name: <INPUT TYPE="text" VALUE=""
NAME="1astName” SIZE=25 onFocus="validateDependentFields()">
<TEXTAREA NAME=,'commentFi el d" R0WS=5 C0LS=50 onFocus="vali dateDependentFi el ds() ">
<B0DY BGC0L0R="white"
on Foeus="document.bgCol or='green ' ">
on Load
The on Load event handler is associated with both the wi ndow (frame) object and the i mage object. You can use the on Load event handler of the wi ndow object in two ways:
Previous << 1 .. 46 47 48 49 50 51 < 52 > 53 54 55 56 57 58 .. 72 >> Next