contentEditable

Compatibility WinIE5.5 , MacIE-, NN-, Moz-, Safari 1.2 IE5.5 introduced the concept of editable HTML content on a page. Element tags can include a contenteditable attribute whose value is echoed via the contentEditable property of the element. The default value for this property is inherit, which means that the property inherits whatever setting this property has in the hierarchy of HTML containers outward to the body. If you set the contentEditable property to true, that element and all nested...

A Browser History Count

lt title gt History Object lt title gt lt script type text javascript gt function showCount var histCount window.history.length if histCount gt 5 alert My, my, you 've been busy. You have visited histCount pages so far. else alert You have been to histCount Web pages this session. lt script gt lt head gt lt body gt lt form gt lt input type button name activity value My Activity onclick showCount gt lt form gt lt body gt lt html gt

documentelementFromPoint

function addEvent elem, evtType, func if elem.addEventListener elem.addEventListener evtType, func, false else if elem.attachEvent elem.attachEvent on evtType, func else elem on evtType func addEvent window, load, function addEvent document, mouseover, showElemUnderneath lt h1 Method lt h1 gt lt hr i d myHR gt lt p id instructions gt Roll the mouse around the page. The coordinates of the mouse pointer are currently atop an element lt br id myBR gt whose ID is lt span id mySpan lt form id myForm...

onseectstart

Compatibility WinIE4 , MacIE4 , NN-, Moz-, Safari 1.3 The onselectstart event handler fires when a user begins to select content on the page. Selected content can be inline text, images, or text within an editable text box. If the user selects more than one object, the event fires in the first object affected by the selection. Use the page from Listing 15-46 to see how the onselectstart event handler works when a user selects across multiple elements on a page. As the user begins a selection...

Exercises

1. Which of the following applications are well suited to client-side JavaScript Why or why not a. Product catalog page that lets visitors view the product in five different colors b. A counter that displays the total number of visitors to the current page d. Graphical Fahrenheit-to-Celsius temperature calculator 2. Which of the following object names are valid in JavaScript For each one that is invalid, explain why. 3. Using the diagram from Figure 4-7 for reference, draw a diagram of the...

onblur and onfocus Event Handlers

lt title gt onblur and onblur Event Handlers lt title gt lt script type text javascript gt function showBlur var id event.srcElement.id alert Element id has blurred. alert Element id has received focus. lt script gt lt head gt lt body gt 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...

readyState

Value String integer for OBJECT object Read-Only Compatibility WinIE4 , MacIE4 , NN-, Moz-, SafariA script can query an element in IE to find out whether it has loaded all ancillary data for example, external image files or other media files before other statements act on that object or its data. The readyState property lets you know the loading status of an element. Table 15-6 lists the possible values and their meanings. 4 Element and data are fully loaded. 3 Data may not be loaded fully, but...

Entering Your First Script

It s time to start creating your first JavaScript script. Launch your text editor and browser. If your browser offers to dial your Internet service provider ISP or begins dialing automatically, cancel or quit the dialing operation. If the browser s Stop button is active, click it to halt any network searching it may try to do. You may receive a dialog-box message or page indicating that the URL for your browser s home page usually the home page of the browser s publisher unless you ve changed...