279Chapter 15Generic HTML Element Objectsfunction whereInWorld(elem) { var (Web hosting support)

279Chapter 15Generic HTML Element Objectsfunction whereInWorld(elem) { var x = event.clientX; var y = event.clientY; var component = document.getElementById( myTextarea ).componentFromPoint(x,y); if (window.event.srcElement == document.getElementById( myTextarea )){ if (component == ) { status = mouseDown event occurred inside the element ; } else { status = mouseDown occurred on the element s + component; } } else { status = mouseDown occurred + component + of the element ; } }

componentFromPoint() Method


Tracking the mouseDown event relative to the textarea object. Viewresults in status bar.

Related Item:eventobject. contains(elementObjectReference) Returns:Boolean. Compatibility:WinIE4+, MacIE4+, NN-, Moz-, Safari- The contains()method reports whether the current object contains another known objectwithin its HTML containment hierarchy. Note that this is not geographical collision detectionof overlapping elements, but rather the determination of whether one element is nestedsomewhere within another. The scope of the contains()method extends as deeply within the current object s hierarchyas is necessary to locate the object. In essence, the contains()method examines all of theelements that are part of an element s allarray. Therefore, you can use this method as ashortcut replacement for a forloop that examines each nested element of a container for theexistence of a specific element. The parameter to the contains()method is a reference to an object. If you have only the ele- ment s ID as a string to go by, you can use the document.getElementById()method to gen- erate a valid reference to the nested element. elementObject.contains()

Leave a Reply