Archive for the 'Tomcat' Category

378Part IIIDocument Objects Referencedifferent document into a (Best web hosting site) window,

Wednesday, February 6th, 2008

378Part IIIDocument Objects Referencedifferent document into a window, use the locationobject (see Chapter 17). The documentobject is described in detail in Chapter 18. Related Items:documentobject. eventValue:Object.Read/WriteCompatibility:WinIE4+, MacIE4+, NN-, Moz-, Safari1+ IE4+ and Safari treat the eventobject as a property of the windowobject. Navigator 4+ andthe W3C DOM (as well as Safari here, too) pass an instance of the Eventobject as an argu- ment to event handler functions. The connection with the windowobject is relatively inconse- quential, because all action involving the eventobject occurs in event handler functions. Theonly difference is that the object can be treated as a more global object when one event han- dler function invokes another. Instead of having to pass the eventobject parameter to thenext function, functions can access the eventobject directly (with or without the window. prefix in the reference). For complete details about the eventobject in all browsers, see Chapter 25. Related Items:eventobject. externalValue:Object.Read-OnlyCompatibility:WinIE4+, MacIE-, NN-, Moz-, Safari- The externalproperty is useful only when the browser window is a component in anotherapplication. The property provides a gateway between the current browser window and theapplication that acts as a host to the browser window component. With WinIE4+ acting as a component to the host operating system, the externalproperty canbe used to access several methods that influence behaviors outside of the browser. Perhapsthe three most useful methods to regular Web page scripters are AddDesktopComponent(), AddFavorite(), and NavigateAndFind(). The first two methods display the same kind ofalert dialog box that users get after making these choices from the browser or desktop menus, so that you won t be able to sneak your Web site onto desktops or Favorites listings withoutthe visitor s approval. Table 16-2 describes the parameters for these three methods. Table 16-2: Popular window.external Object MethodsMethodDescriptionAddDesktopComponentAdds a Web site or image to the Active Desktop (if turned on in the ( URL , type [, user s copy of Windows). The typeparameter value is either left, top, width, websiteor image. Dimensional parameters (optional) are all height])integer values. AddFavoriteAdds the specified URL to the user s Favorites list. The optional title( URL [, title ])string parameter is how the URL should be listed in the menu (ifmissing, the URL appears in the list). NavigateAndFindNavigates to the URL in the first parameter and opens the page in ( URL , findString , the target frame (an empty string opens in the current frame). The target )findStringis text to be searched for on that page andhighlighted when the page loads. windowObject.document

377Chapter 16Window and Frame Objectsbar.visible = !bar.visible; netscape.security.PrivilegeManager.revertPrivilege( (Web hosting script)

Tuesday, February 5th, 2008

377Chapter 16Window and Frame Objectsbar.visible = !bar.visible; netscape.security.PrivilegeManager.revertPrivilege( UniversalBrowserWrite ); } // restore settingsfunction restore() { netscape.security.PrivilegeManager.enablePrivilege( UniversalBrowserWrite ); window.locationbar.visible = originalLocationbar; window.menubar.visible = originalMenubar; window.personalbar.visible = originalPersonalbar; window.scrollbars.visible = originalScrollbars; window.statusbar.visible = originalStatusbar; window.toolbar.visible = originalToolbar; netscape.security.PrivilegeManager.revertPrivilege( UniversalBrowserWrite ); }

Toggle Window Bars








Related Items:window.open()method. documentValue:Object.Read-OnlyCompatibility:WinIE3+, MacIE3+, NN2+, Moz1+, Safari1+ I list the documentproperty here primarily for completeness. Each windowobject contains asingle documentobject (although in Navigator 4, a window may also contain layers, each ofwhich has a documentobject, as described in Chapter 39 on the CD-ROM). The value of thedocumentproperty is the documentobject, which is not a displayable value. Instead, you usethe documentproperty as you build references to properties and methods of the documentand to other objects contained by the document, such as a form and its elements. To load awindowObject.document

376Part IIIDocument Objects ReferenceNavigator 4 promoted these elements (Web site designers)

Tuesday, February 5th, 2008

376Part IIIDocument Objects ReferenceNavigator 4 promoted these elements to first-class objects contained by the windowobject. Navigator 6 added one more feature, called the directories bar a frame-like device that canbe opened or hidden from the left edge of the browser window. At the same time, however, NN6+/Mozilla browsers no longer permit hiding and showing the browser window s scroll- bars. Chrome objects have but one property: visible. Reading this Boolean value (possiblewithout signed scripts) lets you inspect the visitor s browser window for the elements cur- rently engaged. Changing the visibility of these items on the fly alters the relationship between the inner andouter dimensions of the browser window. If you must carefully size a window to display con- tent, you should adjust the chrome elements before sizing the window. Before you startchanging chrome visibility before the eyes of your page visitors, weigh the decision carefully. Experienced users have fine-tuned the look of their browser windows to just the way they likethem. If you mess with that look, you may anger your visitors. Fortunately, changes you maketo a chrome element s visibility are not stored to the user s preferences. However, thechanges you make survive an unloading of the page. If you change the settings, be sure youfirst save the initial settings and restore them with an onunloadevent handler. The Macintosh menu bar is not part of the browser s window chrome. Therefore, its visibilitycannot be adjusted from a script. ExampleIn Listing 16-6, you can experiment with the look of a browser window with any of the chromeelements turned on and off. To run this script, you must either sign the scripts or turn oncodebase principals (see Chapter 46 on the CD-ROM). Java must also be enabled to use thesigned script statements. As the page loads, it stores the current state of each chrome element. One button for eachchrome element triggers the toggleBar()function. This function inverts the visible propertyfor the chrome object passed as a parameter to the function. Finally, the Restore buttonreturns visibility to their original settings. Notice that the restore()function is also calledby the onunloadevent handler for the document. Also, if you load this example into NN6+, non-fatal script errors occur when the scrollbars are turned on or off. Listing 16-6:Controlling Window Chrome Microsoft

Mozilla

windowObject.defaultStatus

Yahoo free web hosting - 372Part IIIDocument Objects ReferenceListing 16-4:Checking Before Closing a

Saturday, February 2nd, 2008

372Part IIIDocument Objects ReferenceListing 16-4:Checking Before Closing a Window


To complete the example of the window opening and closing, notice that the subwindow isgiven a button whose onclickevent handler closes the main window. In modern browsers, the user is presented with an alert asking to confirm the closure of the main browser window. Related Items:window.open(), window.close()methods. Components(See appCore) controllers(See appCore) windowObject.closed

371Chapter 16Window and Frame ObjectsYou cannot use the (Dedicated web hosting)

Friday, February 1st, 2008

371Chapter 16Window and Frame ObjectsYou cannot use the clipboardDataobject to transfer data between pages that originate fromdifferent domains or arrive via different protocols (httpversus https). ExampleSee Listings 15-30 and 15-39 to see how the clipboardDataobject is used with a variety ofedit-related event handlers. Related Items:event.dataTransferproperty; onbeforecopy, onBeforeCut, onbeforepaste, oncopy, oncut, onpasteevent handlers. closedValue:Boolean.Read-OnlyCompatibility:WinIE4+, MacIE4+, NN3+, Moz1+, Safari1+ When you create a subwindow with the window.open()method, you may need to accessobject properties from that subwindow, such as setting the value of a text field. Access to thesubwindow is via the windowobject reference that is returned by the window.open() method, as in the following code fragment: var newWind = window.open( someURL.html , subWind ); … newWind.document.entryForm.ZIP.value = 00000 ; In this example, the newWindvariable is not linked live to the window, but is only a refer- ence to that window. If the user should close the window, the newWindvariable still containsthe reference to the now missing window. Thus, any script reference to an object in that miss- ing window will likely cause a script error. What you need to know before accessing items inasubwindow is whether the window is still open. The closedproperty returns trueif the windowobject has been closed either by script orbythe user. Any time you have a script statement that can be triggered after the user has anopportunity to close the window, test for the closedproperty before executing thatstatement. ExampleIn Listing 16-4, I have created a basic window opening and closing example. The script beginsby initializing a global variable, newWind, which is used to hold the object reference to thesecond window. This value needs to be global so that other functions can reference the win- dow for tasks, such as closing. For this example, the new window contains some HTML code written dynamically to it, ratherthan loading an existing HTML file into it. Therefore, the URL parameter of the window.open() method is left as an empty string. Next comes a brief delay to allow Internet Explorer (espe- cially versions 3 and 4) to catch up with opening the window so that content can be writtento it. The delay (using the setTimeout()method described later in this chapter) invokes thefinishNewWindow()function, which uses the global newWindvariable to reference the win- dow for writing. The document.close()method closes writing to the document a differentkind of close than a window close. A separate function, closeWindow(), is responsible forclosing the subwindow. As a final test, an ifcondition looks at two conditions: 1) if the windowobject has ever beeninitialized with a value other than null(in case you click the window closing button beforeever having created the new window) and 2) if the window s closedproperty is nullorfalse. If either condition is true, the close()method is sent to the second window. windowObject.closed

Make my own web site - 370Part IIIDocument Objects Referencesubjects that extend well beyond

Thursday, January 31st, 2008

370Part IIIDocument Objects Referencesubjects that extend well beyond the scope of this book. You can begin to explore this sub- ject within the context of Mozilla-based browsers and scripting athttp://www.mozilla.org/scriptable/. clientInformationValue:navigator object.Read-OnlyCompatibility:WinIE4+, MacIE4+, NN-, Moz-, Safari- In an effort to provide scriptable access to browser-level properties while avoiding referenceto the Navigator browser brand, Microsoft provides the clientInformationproperty. Itsvalue is identical to that of the navigatorobject an object name that is also available in IE. Use the navigatorobject for cross-browser applications. (See Chapter 38 on the CD-ROM.) Related Items:navigatorobject. clipboardDataValue:Object.Read/WriteCompatibility:WinIE5+, MacIE-, NN-, Moz-, Safari- Use the clipboardDataobject to transfer data for such actions as cutting, copying, and past- ing under script control. The object contains data of one or more data types associated witha transfer operation. Use this property only when editing processes via the Edit menu (orkeyboard equivalents) or context menu controlled by script typically in concert with edit- related event handlers. Working with the clipboardDataobject requires knowing about its three methods, shown inTable 16-1. Familiarity with the edit-related event handlers ( before and after versions ofcut, copy, and paste) is also helpful (see Chapter 15). Table 16-1: window.clipboardData Object MethodsMethodReturnsDescriptionclearData([format])NothingRemoves data from the clipboard. If no formatparameter is supplied, all data is cleared. Dataformats can be one or more of the following strings: Text, URL, File, HTML, Image. getData(format)StringRetrieves data of the specified format from theclipboard. The format is one of the following strings: Text, URL, File, HTML, Image. The clipboard is notemptied when you get the data, so that the data canbe retrieved in several sequential operations. setData(format, data)BooleanStores string data in the clipboard. The format is oneof the following strings: Text, URL, File, HTML, Image. For non-text data formats, the data must bea string that specifies the path or URL to the content. Returns trueif the transfer to the clipboard issuccessful. windowObject.appCore

369Chapter 16Window and Frame ObjectsWindow properties are far (Cpanel web hosting)

Wednesday, January 30th, 2008

369Chapter 16Window and Frame ObjectsWindow properties are far more flexible on all browsers when your scripts generate a newwindow (with the window.open()method): You can influence the size, toolbar, or other viewoptions of a window. Recent browser versions provide even more options for new windows, including the position of the window and whether the window should even display a title bar. Again, if an option can conceivably be used to deceive a user (for example, silently hiding onewindow that monitors activity in another window), signed scripts and/or user permission arenecessary. The windowobject is also the level at which a script asks the browser to display any of threestyles of dialog boxes (a plain alert dialog box, an OK/Cancel confirmation dialog box, or aprompt for user text entry). Although dialog boxes are extremely helpful for cobblingtogether debugging tools for your own use (see Chapter 45 on the CD-ROM), they can be verydisruptive to visitors who navigate through Web sites. Because most JavaScript dialog boxesare modal (that is, you cannot do anything else in the browser until you dismiss the dialogbox), use them sparingly, if at all. Remember that some users may create macros on theircomputers to visit sites unattended. Should such an automated access of your site encountera modal dialog box, it is trapped on your page until a human intervenes. All dialog boxes generated by JavaScript identify themselves as being generated byJavaScript. This is primarily a security feature to prevent deceitful scripts from creating sys- tem- or application-style dialog boxes that convince visitors to enter private information. Itshould also discourage dialog box usage in Web page design. And that s good, because dialogboxes tend to annoy users. With the exception of the IE-specific modal and modeless dialog boxes (see the window.showModalDialog()and window.showModeless()methods), JavaScript dialog boxes arenot particularly flexible in letting you fill them with text or graphic elements beyond the basics. In fact, you can t even change the text of the dialog box buttons or add a button. With DHTML- capable browsers, you can use positioned divor iframeelements to simulate dialog boxbehavior in a cross-browser way. With respect to the W3C DOM, the window is outside the scope of the standard throughDOMLevel 2. The closest that the standard comes to acknowledging a window at all is thedocument.defaultViewproperty, which evaluates to the windowobject in today s browsers(predominantly Mozilla). But the formal DOM standard specifies no properties or methodsforthis view object. PropertiesappCoreComponents[] controllers[] promptersidebarValues:See text.Read-OnlyCompatibility:WinIE-, MacIE-, NN6+, Moz1+, Safari- NN6+/Mozilla provides scriptable access to numerous services that are part of the xpconnectpackage ( xp stands for cross-platform ). These services allow scripts to work with COMobjects and the mozilla.org XUL (XML-based User Interface Language) facilities lengthywindowObject.appCore