Dictionary
While the Dictionary object is very helpful to VBScript authors, JavaScript already provides the equivalent functionality natively. A Dictionary object behaves very much like a JavaScript array that has string index values similar to a Java hash table , although numeric index values are also acceptable in the Dictionary. Indexes are called keys in this environment. VBScript arrays do not have this facility natively, so the Dictionary object supplements the language for the sake of convenience....
Listing Creating the Dispatch Lookup Table
Begin validation dispatching mechanism function dispatcher validationFunc this.doValidate validationFunc new dispatcher isNotEmpty new dispatcher isPositivelnteger new dispatcher isDollarsOnly8 dispatchLookup isUSState new dispatcher isUSState dispatchLookup isZip new dispatcher isZip new dispatcher isExpandedZip dispatchLookup isPhone new dispatcher isPhone dispatchLookup isConfirmed new dispatcher isConfirmed dispatchLookup isNY new dispatcher isNY dispatchLookup isNum16 new dispatcher...
isContentEditable
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 The isContentEditable property returns a Boolean value indicating whether a particular element object is set to be editable see the preceding discussion of the contentEditable property . This property is helpful because if a parent element's contentEditable property is set to true, a nested element's contentEditable property likely is set to its default value inherit. But because its parent is editable, the isContentEditable property of the nested...
contentDocument 1
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 The contentDocument property of an IFRAME element object is nothing more than a reference to the document contained by that frame. If your script finds that it has a reference to an IFRAME element object, you can use the contentDocument property to get a valid reference to the document, and therefore any other content of the frame.
Listing Adding a ReadOnly Prototype Property to All HTML Element Objects
lt SCRIPT LANGUAGE JavaScript1.5 gt if HTMLElement function var result elementNodes 0, textNodes 0 for var i 0 i lt this.childNodes.length i switch this.childNodes i .nodeType case 1 To access the property, use it like any other property of the object. For example var BodyNodeDetail document.body.childNodeDetail The returned value in this example is an object, so you use regular JavaScript syntax to access one of the property values var BodyElemNodesCount
accessKey
Value One-Character String Read Write NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility For many elements, you can specify a keyboard character letter, numeral, or punctuation symbol that, when typed as an Alt key combination on the Win32 OS platform or Ctrl key combination on the MacOS , brings focus to that element. An element that has focus is the one that is set to respond to keyboard activity. If the newly focused element is out of view in the document's current scroll position,...
innerHTML innerText
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 One way that Internet Explorer exposes the contents of an element is through the innerHTML and innerText properties. Navigator 6 offers only the innerHTML property. All content defined by these inner properties consists of document data that is contained by an element's start and end tags, but not including the tags themselves see outerText and outerHTML properties . Setting these inner properties is a common way to modify a portion of a page's...
Chapter Application CrossBrowser DHTML Map Puzzle
The Puzzle Implementation Lessons Chapter 57 Application Transforming XML Data Islands 1415 Application Overview 1416 Implementation The Dreams of Other Views 1428 What About Appendix A JavaScript and Browser Object Quick Reference . . . 1433 Appendix B JavaScript Reserved Words 1447 Appendix C Answers to Tutorial Exercises 1449 Chapter 4 Answers 1449 Chapter 5 Answers 1450 Chapter 6 Answers 1451 Chapter 7 Answers 1452 Chapter 8 Answers 1456 Chapter 9 Answers 1457 Chapter 10 Chapter 11 Chapter...
hideFocus
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility In IE for Windows, button types of form controls and links display a dotted rectangle around some part of the element whenever that element has focus. If you set the TABINDEX attribute or tabIndex property of any other kinds of elements in IE5 , they, too, display that dotted line when given focus. You can still let an element receive focus, but hide that dotted line, by setting the hideFocus property of the element object to true...
htmlFor
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility The htmlFor property is a string that contains the ID of the form control element with which the label is associated. This value is normally set via the HTMLFOR attribute in the LABEL element's tag. Modifying this property does not alter the position or rendering of the label, but it does change the relationships between label and control. For HTML element properties, methods, and event handlers, see Chapter 15.
NN NN NN NN IEJ IEJ IE IE IE Compatibility 4
The contains method reports whether the current object contains another known object within its HTML containment hierarchy. Note that this is not geographical collision detection of overlapping elements, but rather the determination of whether one element is nested somewhere within another. The scope of the contains method extends as deeply within the current object's hierarchy as is necessary to locate the object. In essence, the contains method examines all of the elements that are part of an...
Listing onBlur and onFocus Event Handlers
lt TITLE gt onBlur and onBlur Event Handlers lt TITLE gt lt SCRIPT LANGUAGE JavaScript gt function showBlur var id event.srcElement.id alert Element id has blurred. alert Element id has received focus. lt H1 ID H1 TABINDEX 2 gt onBlur and onBlur Event Handlers lt H1 gt lt HR gt lt P ID P1 onBlur showBlur ipsum dolor sit amet, consectetaur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim adminim veniam, quis nostrud exercitation ullamco laboris nisi...
canHaveChildren
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility Useful in some dynamic content situations, the canHaveChildren property not implemented in IE5 Mac reveals whether a particular element is capable of containing a child nested element. Most elements that have start and end tags particularly the generic elements covered in this chapter can contain nested elements. In modern object models, a nested element is referred to as a child of its parent container. On the Example with Listing 15-2...
parentElement 1
NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 IE5.5 Compatibility The parentElement method returns a reference to the next outermost HTML element container that holds the text range boundaries. If the text range boundaries are at the boundaries of a single element, the parentElement method returns that element's reference. But if the boundaries straddle elements, then the object returned by the method is the element that contains the text of the least-nested text portion. In contrast to the expand and...
Core JavaScriptJScriptECMAScript NN IE Quick Reference
constructor 'IE4 concat array2 N4 gt IE4 length jolnfc iar pop ' IE5 5 reversed shift IE5 5 slice i, j N4-IE4 sort compareFunc splice lj , items I 1.IE55 constructor -IE4 getFullYear lt J2 prototype3'IE4 getYear getMonth getDateO getDayO getHours getMlnutes getSeconds getTlme getMlllisecondsO N4J2 getUTCFullYear N4'J2 getUTCMonthQ , J2 getUTCDate r4'J2 getUTCDayO , J2 getUTCHours N4'J2 getUTCMInutes N4'J2 getUTCSeconds J2 getUTCMIIIisecondsO N4 J2 s amp tY amp ar va setFullYear vaif4-J2...
contentEditable 1
Listing 15-7 is a simplified demonstration of how to turn some text inside a document into an editable element. When you click the button of a freshly loaded page, the toggleEdit function captures the opposite of the current editable state via the isContentEditable property of the DIVthat is subject to edit. You switch on editing for that element in the next statement by assigning the new value to the contentEditable property of the DIV. For added impact, turn the text of the DIV to red to...
Document Object
Properties Methods Event Handlers