Archive for January, 2008

360Part IIIDocument Objects Referencehave a document that requires (Net web server)

Thursday, January 24th, 2008

360Part IIIDocument Objects Referencehave a document that requires considerable scrolling to get through, you may want to main- tain a static set of navigation controls visible at all times. By placing those controls be theylinks or image maps in a separate frame, you have made the controls available for immedi- ate access, regardless of the scrolled condition of the main document. Creating framesThe task of defining frames in a document remains the same whether or not you re usingJavaScript. The simplest framesetting document consists of tags that are devoted to settingup the frameset, as follows: The preceding HTML document, which the user never sees, defines the frameset for theentire browser window. Each frame must have a URL reference (specified by the srcattribute) for a document to load into that frame. For scripting purposes, assigning a nametoeach frame with the nameattribute greatly simplifies scripting frame content. The frame object modelPerhaps the key to successful frame scripting is understanding that the object model in thebrowser s memory at any given instant is determined by the HTML tags in the currentlyloaded documents. All canned object model graphics in this book, such as Figure 16-1, do notreflect the precise object model for your document or document set. For a single, frameless document, the object model starts with just one windowobject, whichcontains one document, as shown in Figure 16-1. In this simple structure, the windowobjectisthe starting point for all references to any loaded object. Because the window is alwaysthere it must be there for a document to load into a reference to any object in the docu- ment can omit a reference to the current window. In a simple two-framed frameset model (see Figure 16-2), the browser treats the container ofthe initial, framesetting document as the parent window. The only visible evidence that thedocument exists is that the framesetting document s title appears in the browser windowtitlebar. Figure 16-1:The simplest window document relationship. WindowDocument

Simple web server - Window andFrameObjectsAquick look at the basic document object

Thursday, January 24th, 2008

Window andFrameObjectsAquick look at the basic document object model diagram inChapter 14 (see Figure 14-1) reveals that the windowobject isthe outermost, most global container of all document-related objectsthat you script with JavaScript. All HTML and JavaScript activitytakes place inside a window. That window may be a standardWindows, Mac, or XWindows application-style window, complete withscrollbars, toolbars, and other chrome; you can also generate win- dows that have only some of a typical window s chrome. A frame isalso a window, even though a frame doesn t have many accou- trements beyond scroll bars. The windowobject is where everythingbegins in JavaScript references to objects. IE4+, NN6+, and W3Cbrowsers treat the frameset as a special kind of windowobject, sothat it is also covered in this chapter. Of all the objects associated with browser scripting, the windowandwindow-related objects have by far the most object-specific terminol- ogy associated with them. This necessitates a rather long chapter tokeep the discussion in one place. Use the running footers as a naviga- tional aid through this substantial collection of information. Window TerminologyThe windowobject is often a source of confusion when you firstlearnabout the document object model. A number of synonyms forwindowobjects muck up the works: top, self, parent, and frame. Aggravating the situation is that these terms are also properties of awindowobject. Under some conditions, a window is its own parent, but if you define a frameset with two frames, you have only one par- ent among a total of three windowobjects. It doesn t take long beforethe whole subject can make your head hurt. If you do not use frames in your Web applications, all of theseheadaches never appear. But if frames are part of your design plan, you should get to know how frames affect the object model. FramesThe application of frames has become a religious issue among Webdesigners: some swear by them; others swear at them. I believe therecan be compelling reasons to use frames at times. For example, if you1616CHAPTER …In This ChapterScriptingcommunication amongmultiple framesCreating and managingnew windowsControlling the size, position, andappearance of thebrowser windowDetails of window, frame, frameset, andiframeobjects …

Web server on xp - 358Part IIIDocument Objects ReferenceListing 15-46(continued) td {text-align:center} function

Wednesday, January 23rd, 2008

358Part IIIDocument Objects ReferenceListing 15-46(continued)

onselectstart Event Handler



This is a sample paragraph.

Column A Column B Column C
text text text
text text text

Related Item:onselectevent handler for a variety of objects. … elementObject.onselectstart

357Chapter 15Generic HTML Element (Web design rates) ObjectsRelated Item:readyStateproperty. onresizeCompatibility:WinIE4+, MacIE4+,

Tuesday, January 22nd, 2008

357Chapter 15Generic HTML Element ObjectsRelated Item:readyStateproperty. onresizeCompatibility:WinIE4+, MacIE4+, NN4+, Moz1+, Safari1+ The onresizeevent handler fires whenever an object is resized in response to a variety ofuser or scripted actions. Most elements include this event handler, provided the object hasdimensional style attributes (for example, height, width, or position) assigned to it. In IE4+ and NN6+/Moz1+, the onresizeevent does not bubble. Resizing the browser windowor frame does not cause the window s onloadevent handler to fire. ExampleIf you want to capture the user s resizing of the browser window (or frame), you can assign afunction to the onresizeevent handler either via scriptwindow.onresize = handleResize; or by an HTML attribute of the bodyelement: Related Item:window.resize()method. onresizeendonresizestartCompatibility:WinIE5.5+, MacIE-, NN-, Moz-, Safari- The onresizeendand onresizestartevent handlers fire only on a resizable object inWindows edit mode. Related Item:oncontrolselectevent handler. onselectstartCompatibility:WinIE4+, MacIE4+, NN-, Moz-, Safari- The onselectstartevent 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 field. If the userselects more than one object, the event fires in the first object affected by the selection. ExampleUse the page from Listing 15-46 to see how the onselectstartevent handler works when auser selects across multiple elements on a page. As the user begins a selection anywhere onthe page, the ID of the object receiving the event appears in the status bar. Notice that theevent doesn t fire until you actually make a selection. When no other element is under thecursor, the bodyelement fires the event. Listing 15-46: Using the onselectstart Event Handler ContinuedelementObject.onselectstart

Web hosting e commerce - 356Part IIIDocument Objects ReferenceListing 15-45(continued) function normalText() {

Tuesday, January 22nd, 2008

356Part IIIDocument Objects ReferenceListing 15-45(continued)

onpropertychange Event Handler



This is a sample paragraph.

Text: Normal Short
Color: Black Red

Related Items:styleproperty; setAttribute()method. onreadystatechangeCompatibility:WinIE4+, MacIE4+, NN-, Moz-, Safari- The onreadystatechangeevent handler fires whenever the ready state of an object changes. See details about these states in the discussion of the readyStateproperty earlier in thischapter (and notice the limits for IE4). The change of state does not guarantee that an objectis, in fact, ready for script statements to access its properties. Always check the readyStateproperty of the object in any script that the onreadystatechangeevent handler invokes. This event fires for objects that are capable of loading data: applet, document, frame, frameset, iframe, img, link, object, script, and XML objects. The event doesn t fire forother types of objects unless a Microsoft DHTML behavior is associated with the object. Theonreadystatechangeevent does not bubble, nor can you cancel it. elementObject.onpropertychange

Web hosting script - 355Chapter 15Generic HTML Element Objectstruck round doll red

Monday, January 21st, 2008

355Chapter 15Generic HTML Element Objects truck round doll red ball pretty

Pat said, Oh my, the       is so      !

Related Items:oncopy, oncut, onbeforepasteevent handlers. onpropertychangeCompatibility:WinIE5+, MacIE-, NN-, Moz-, Safari- The onpropertychangeevent fires in WinIE5+ whenever a script modifies an object s prop- erty. This includes changes to the properties of an object s style. Changing properties by wayof the setAttribute()method also triggers this event. A script can inspect the nature of the property change because the event.propertyNameproperty contains the name (as a string) of the property that was just changed. In the case ofa change to an object s styleobject, the event.propertyNamevalue begins with style. as in style.backgroundcolor. You can use this event handler to localize any object-specific post-processing of changes toan object s properties. Rather than include the post-processing statements inside the func- tion that makes the changes, you can make that function generalized (perhaps to modifyproperties of multiple objects). ExampleListing 15-45 shows how you can respond programmatically to an object s properties beingchanged. The page generated by the listing contains four radio buttons that alter the innerHTMLand style.colorproperties of a paragraph. The paragraph s onpropertychangeevent handlerinvokes the showChange()function, which extracts information about the event and displaysthe data in the status bar of the window. Notice how the property name includes style.whenyou modify the stylesheet property. Listing 15-45: Using the onPropertyChange Property ContinuedelementObject.onpropertychange

354Part IIIDocument Objects ReferenceAt paste time, the innerHTMLproperty (Web host forum)

Sunday, January 20th, 2008

354Part IIIDocument Objects ReferenceAt paste time, the innerHTMLproperty of the target spanis set to the text data stored in theclipboard. The event.returnValueproperty is set to falsehere, as well, to prevent normalsystem pasting from interfering with the controlled version. Listing 15-44: Using onbeforepaste and onpaste Event Handlers

onbeforepaste and onpaste Event Handlers


Your goal is to copy and paste one noun and one adjective from thefollowing table into the blanks of the sentence. Select a word fromthe table and copy it to the clipboard. Select one or more spaces ofthe blanks in the sentence and choose Paste to replace the blank withthe clipboard contents.

elementObject.onpaste

353Chapter 15Generic HTML Element Objectsonmouseover= return setStatus( View dictionary definition ) (Web server certificate)

Sunday, January 20th, 2008

353Chapter 15Generic HTML Element Objectsonmouseover= return setStatus( View dictionary definition ) onmouseout= return setStatus( ) >allegiance to the flag of the United States of America, and tothe Republic for which it stands, one nation under God, indivisible, withliberty and justice for all. Related Items:onmouseenter, onmouseleave, onmousemoveevent handlers. onpasteCompatibility:WinIE5+, MacIE-, NN-, Moz-, Safari- The onpasteevent fires immediately after the user or script initiates a paste edit action onthe current object. The event is preceded by the onbeforepasteevent, which fires prior toany edit or context menu that appears (or before the paste action if initiated by keyboardshortcut). Use this event handler to provide edit functionality to elements that don t normally allowpasting. In such circumstances, you need to enable the Paste menu item in the context or Editmenu by setting the event.returnValuefor the onbeforepasteevent handler to false. Then your onpasteevent handler must manually retrieve data from the clipboard (by way ofthe getData()method of the clipboardDataobject) and handle the insertion into the cur- rent object. Because you are in charge of what data is stored in the clipboard, you are not limited to adirect copy of the data. For example, you might wish to store the value of the srcproperty ofan image object so that you can paste it elsewhere on the page. ExampleListing 15-44 demonstrates how to use the onbeforepasteand onpasteevent handlers (in conjunction with onbeforecopyand oncopy) to let scripts control the data-transfer process during a copy-and-paste user operation. A table contains words to be copied (onecolumn of nouns, one column of adjectives) and then pasted into blanks in a paragraph. Theonbeforecopyand oncopyevent handlers are assigned to the tableelement because theevents from the tdelements bubble up to the tablecontainer and there is less HTML codeto contend with. Inside the paragraph, two spanelements contain underscored blanks. To paste text into theblanks, the user must first select at least one character of the blanks. (See Listing 15-37, which gives a drag-and-drop version of this application.) The onbeforepasteevent handlerin the paragraph (which gets the event as it bubbles up from either span) sets the event. returnValueproperty to false, thus allowing the Paste item to appear in the context andEdit menus (not a normal occurrence in HTML body content). elementObject.onpaste

Web site design - 352Part IIIDocument Objects ReferenceonmouseoutonmouseoverCompatibility:WinIE3+, MacIE3+, NN2+, Moz1+, Safari1+

Saturday, January 19th, 2008

352Part IIIDocument Objects ReferenceonmouseoutonmouseoverCompatibility:WinIE3+, MacIE3+, NN2+, Moz1+, Safari1+ The onmouseoverevent fires for an object whenever the cursor rolls into the rectangularspace of the object on the screen. The onmouseoutevent handler fires when you move thecursor outside the object s rectangle. These events most commonly display explanatory textabout an object in the window s status bar and effect image swapping (so-called mouserollovers). Use the onmouseoverevent handler to change the state to a highlighted version; use the onmouseoutevent handler to restore the image or status bar to its normal setting. While these two events have been in object models of scriptable browsers since the beginning, they were not available to most objects in earlier browsers. IE4+ and W3C DOM-compatiblebrowsers provide support for these events on every element that occupies space on the screen. IE5.5+ includes an additional pair of event handlers onmouseenterand onmouseleave thatduplicate the onmouseoverand onmouseoutevents but with different terminology. The oldevent handlers fire just before the new versions. The onmouseoutevent handler commonly fails to fire if the event is associated with an ele- ment that is near a frame or window edge and the user moves the cursor quickly outside ofthe current frame. ExampleListing 15-43 uses the U.S. Pledge of Allegiance with four links to demonstrate how to use theonmouseoverand onmouseoutevent handlers. Notice that for each link, the handler runs ageneral-purpose function that sets the window s status message. The function returns a truevalue, which the event handler call evaluates to replicate the required returntruestate- ment needed for setting the status bar. In one status message, I supply a URL in parenthesesto let you evaluate how helpful you think it is for users. Listing 15-43: Using onmouseover and onmouseout Event Handlers

onmouseover and onmouseout Event Handlers



Pledge of Allegiance


I pledge

351Chapter 15Generic (Web server application) HTML Element ObjectsIE4+ and W3C browsers

Friday, January 18th, 2008

351Chapter 15Generic HTML Element ObjectsIE4+ and W3C browsers simplify the implementation of this kind of three-state image buttonby allowing you to assign the event handlers directly to imgelement objects. Wrappingimages inside links is a backward-compatibility approach that allows older browsers torespond to clicks on images for navigation or other scripting tasks. Related Item:onclickevent handler. onmouseenteronmouseleaveCompatibility:WinIE5.5+, MacIE-, NN-, Moz-, Safari- WinIE5.5 introduced the onmouseenterand onmouseleaveevent handlers. Both event han- dlers operate just like the onmouseoverand onmouseoutevent handlers, respectively. Microsoft simply offers an alternate terminology. The old and new events continue to fire inIE5.5+. The old ones fire just before the new ones for each act of moving the cursor atop, andexiting from atop, the object. If you are scripting exclusively for IE5.5+, you should use thenew terminology; otherwise, stay with the older versions. ExampleYou can modify Listing 15-43 with the IE5.5 syntax by substituting onmouseenterforonmouseoverand onmouseleavefor onmouseout. The effect is the same. Related Items:onmouseover, onmouseoutevent handlers. onmousemoveCompatibility:WinIE4+, MacIE4+, NN4+, Moz1+, Safari1+ The onmousemoveevent handler fires whenever the cursor is atop the current object and themouse is moved, even by a single pixel. You do not have to press the mouse button for theevent to fire, although the event is most commonly used in element dragging especially inNN/Mozilla, where no ondragevent handler is available. Even though the granularity of this event can be at the pixel level, you should not use thenumber of event firings as a measurement device. Depending on the speed of cursormotion and the performance of the client computer, the event may not fire at every pixellocation. In NN4, you cannot assign the onmousemoveevent handler to any object by way of tagattributes. But you can use the NN4 event capturing mechanism to instruct (via scripting) a window, document, or layerobject to capture mouseMoveevents. This allows for NN4scripts to produce positioned element (layer) dragging. In IE4+ and W3C DOM-compatiblebrowsers, however, you can assign the onmousemoveevent handler to any element(although you can drag only with positioned elements). When designing a page thatencourages users to drag multiple items on a page, it is most common to assign theonmousemoveevent handler to the documentobject and let all such events bubble up tothe document for processing. ExampleSee Chapters 39 and 56 on the CD-ROM for examples of using mouse events to control ele- ment dragging on a page. Related Items:ondrag, onmousedown, onmouseupevent handlers. elementObject.onmousemove


Nouns Adjectives