Affordable web hosting - 90Part IIJavaScript TutorialYou can generally navigate to a

90Part IIJavaScript TutorialYou can generally navigate to a page in your own Web site by specifying a relative URL (thatis, relative to the currently loaded page) rather than the complete URL with protocol andhost information. For pages outside of the domain of the current page, you need to specifythe complete URL. If the page to be loaded is in another window or frame, the window reference must be part ofthe statement. For example, if your script opens a new window and assigns its reference to avariable named newWindow, the statement that loads a page into the subwindow isnewWindow.location.href = http://www.dannyg.com ; The navigator ObjectDespite a name reminiscent of the Netscape Navigator branded browser, the navigatorobjectis implemented in all scriptable browsers. All browsers also implement a handful of propertiesthat reveal the same kind of information that browsers send to servers with each page request. Thus, the navigator.userAgentproperty returns a string text with numerous details aboutthe browser and operating system. For example, a script running in Internet Explorer 6 inWindows XP receives the following value for the navigator.userAgentproperty: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461) The same script running in Mozilla 1.4 on a Macintosh reveals the following userAgentdetails: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624You have already used two other navigator properties (navigator.appVersionand navigator.appName) in your first script of Chapter 3. See Chapter 38 on the CD-ROM formore details about this object and the meaning of the values returned by its properties. Itwas once used extensively to branch script execution according to various browser ver- sions.Chapter 14 describes more modern ways to accomplish browser version detection. The document ObjectThe documentobject holds the real content of the page. Properties and methods of the docu- mentobject generally affect the look and content of the document that occupies the window. All W3C DOM-compatible browsers (and IE4) allow script access to the text con-tents of apage once the document has loaded. However, as you saw in your first script of Chapter 3, the document.write()method lets a script dynamically create content as the page loads onany browser. Many documentobject properties are arrays of other objects in the document, which provide additional ways to reference these objects (over and above the document.getElementById()method). Accessing a documentobject s properties and methods is straightforward, as shown in thefollowing syntax examples: [window.]document.propertyName[window.]document.methodName([parameters]) The windowreference is optional when the script is accessing the documentobject that con- tains the script. If you want a preview of the long list of documentobject properties of thebrowser you re using, enter documentinto the bottom text box of The Evaluator Jr. and pressEnter/Return. The object s properties and current values appear in the Results box. Followingare some of the most commonly used properties and methods of the documentobject.