Archive for September, 2007

62 Part III . Document Objects Reference Calling

Saturday, September 15th, 2007

62 Part III . Document Objects Reference Calling these objects JavaScript objects is not entirely correct. These are really browser document objects: you just happen to use the JavaScript language to bring them to life. Some scripters of Microsoft Internet Explorer use the VBScript lan guage to script the very same document objects. Technically speaking, JavaScript objects apply to data types and other core language objects separate from the doc ument. The more you can keep document and core language objects separate in your head, the more quickly you can deal with browser brand compatibility issues. Hierarchy as road map For the programmer, the primary role of the document object hierarchy is to pro vide scripts with a way to reference a particular object among all the objects that a browser window can contain. The hierarchy acts as a road map the script can use to know precisely which object to address. Consider, for a moment, a scene in which you and your friend Tony are in a high school classroom. It s getting hot and stuffy as the afternoon sun pours in through the wall of windows on the west side of the room. You say to Tony, Would you please open a window? and motion your head toward a particular window in the room. In programming terms, you ve issued a command to an object (whether or not Tony appreciates the comparison). This human interaction has many advan tages over anything you can do in programming. First, by making eye contact with Tony before you speak, he knows that he is the intended recipient of the command. Second, your body language passes along some parameters with that command, pointing ever so subtly to a particular window on a particular wall. If, instead, you are in the principal s office using the public address system, and you broadcast the same command, Would you please open a window?, no one knows what you mean. Issuing a command without directing it to an object is a waste of time because every object thinks, That can t be meant for me. To accom plish the same goal as your one-on-one command, the broadcast command has to be something like, Would Tony Jeffries in Room 312 please open the middle win dow on the west wall? Let s convert this last command to JavaScript dot syntax form (see Chapter 4). Recall from the tutorial that a reference to an object starts with the most global point of view and narrows to the most specific point of view. From the point of view of the principal s office, the location hierarchy of the target object is room312.Jeffries.Tony You can also say that Tony s knowledge about how to open a window is one of Tony s methods. The complete reference to Tony and his method then becomes room312.Jeffries.Tony.openWindow() Your job isn t complete yet. The method requires a parameter detailing which window to open. In this case, the window you want is the middle window of the west wall of Room 312. Or, from the hierarchical point of view of the principal s office, it becomes room312.westWall.middleWindow This object road map is the parameter for Tony s openWindow()method. Therefore, the entire command that comes over the PA system is room312.Jeffries.Tony.openWindow(room312.westWall.middleWindow)
We recommend high quality webhost to host and run your jsp application: christian web host services.

Post office web site - Document Object Model Essentials Without question, the biggest

Saturday, September 15th, 2007

Document Object Model Essentials Without question, the biggest challenge facing client- side Web scripters is the sometimes-baffling array of document object models that have competed for our attention throughout the short history of scriptable browsers. Netscape got the ball rolling in Navigator 2 with the first object model. By the time the version 4 browsers came around, the original object model had gained not only some useful cross-browser features, but also a host of features that were unique to only Navigator or Internet Explorer. The object models were diverging, causing no end of headaches for page authors whose scripts had to run on as many browsers as possible. A ray of hope emerged from the standards process of the World Wide Web Consortium (W3C) in the form of a document object model (DOM) recommendation. The new DOM brings forward much of the original object model, plus new ways of addressing every object in a document. The goal of this chapter is to put each of the object models into perspective and help you select the model(s) you intend to support in your Web applications. But before we get to those specifics, let s examine the role of the object model in designing scripted applications. The Object Model Hierarchy In the tutorial chapters of Part II, you were introduced to the fundamental ideas behind a document object hierarchy in scriptable browsers. In other object-oriented environments, object hierarchy plays a much greater role than it does in JavaScript-able browsers. (In JavaScript, you don t have to worry about related terms, such as classes, inheritance, and instances.) Even so, you cannot ignore the hierarchy concept because much of your code relies on your ability to write ref erences to objects that depend on their positions within the hierarchy. 14 CHAPTER …. In This Chapter Object models versus browser versions Proprietary model extensions Structure of the W3C DOM Mixing object models in a single document ….
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Web server on xp - 60 Part III . Document Objects Reference Values

Friday, September 14th, 2007

60 Part III . Document Objects Reference Values are passed by reference and by value. An object passed to a function is actually a reference to that object, offering full read/write access to properties and methods of that object. But other types of values (including object properties) are passed by value, with no reference chain to the original object. Thus, the following nonsense fragment empties the text box when the onChange event fires: function emptyMe(arg1) { arg1.value = } … But in the following version, nothing happens to the text box: function emptyMe(arg1) { arg1 = } … The local variable (arg1) simply changes from Howdy to an empty string. Error trapping techniques depend on JavaScript version. There is no error trapping in NN2 or IE3. Error trapping in NN3, NN4, and IE4 is event-driven in the Web browser object model. JavaScript, as implemented in IE5 and NN6, supports try-catch and throwstatements, as well as built-in error objects that are not dependent on the host environment. Memory management is not under script control. The host environment man ages memory allocation, including garbage collection. Different browsers may han dle memory in different ways. White space (other than a line terminator) is insignificant. Space and tab characters may separate lexical units (for example, keywords, identifiers, and so on). A line terminator is usually treated as a statement delimiter. Except in very rare constructions, JavaScript parsers automatically insert the semicolon state ment delimiter whenever they encounter one or more line terminators (for exam ple, carriage returns or line feeds). A semicolon delimiter is required between two statements on the same physical line of source code. Moreover, string literals may not have carriage returns in their source code (but an escaped newline character (n) may be a part of the string). Onward to Object Models The core language is only a small part of what you work with while scripting Web pages. The bulk of your job entails understanding the ins and outs of document object models as implemented in several generations of browsers. That s where the next chapter picks up the essentials story. …
We recommend high quality webhost to host and run your jsp application: christian web host services.

59Chapter 13 .JavaScript Essentials example, all properties of (Web site layout)

Friday, September 14th, 2007

59Chapter 13 .JavaScript Essentials example, all properties of the Mathobject act as constant values (for example, Math.PI). You can add properties or methods to working objects at will. To add a property to an object, simply assign a value of any type to it. For example, to add an author property to a string object named myText, use: myText.author = Jane Assign a function reference to an object property to give that object a new method: // function definition function doSpecial(arg1) { // statements } // assign function reference to method name myObj.handleSpecial = doSpecial … // invoke method myObj.handleSpecial(argValue) Inside the function definition, the thiskeyword refers to the object that owns the method. JavaScript objects employ prototype-based inheritance. All object constructors create working objects whose properties and methods inherit the properties and methods defined for the prototype of that object. Starting with NN3 and IE3/J2, scripts can add and delete custom properties and/or methods associated with the static object s prototype so that new working objects inherit the current state of the prototype. Scripts can freely override prototype property values or assign different functions to prototype methods in a working object if desired without affecting the static object prototype. But if inherited properties or methods are not modified in the current working object, any changes to the static object s prototype are reflected in the working object. (The mechanism is that a reference to an object s property works its way up the prototype inheritance chain to find a match to the property name.) JavaScript includes a large set of operators. You can find most operators that you are accustomed to working with in other languages. JavaScript provides typical control structures. All versions of JavaScript offer if, if-else, for, and whileconstructions. JavaScript 1.3 (NN4+ and IE4+) also add do-while and switchconstructions. Iteration constructions provide break and continue statements to modify control structure execution. JavaScript functions may or may not return a value. There is only one kind of JavaScript function. A value is returned only if the function includes a returnkeyword followed by the value to be returned. Return values can be of any data type. JavaScript functions cannot be overloaded. A JavaScript function accepts zero or more arguments, regardless of the number of parameter variables defined for the function. All arguments are automatically assigned to the arguments array, which is a property of a function object. Parameter variable data types are not predefined.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

58 Part III . Document Objects Reference (Web hosting domain) any

Thursday, September 13th, 2007

58 Part III . Document Objects Reference any of the built-in objects plus the newoperator. For example, the following expression generates a String object and returns a reference to that object: new String( Hello ) Table 13-1 lists the built-in objects with which scripters come in contact. Table 13-1 JavaScript Built-in Objects Array1 Boolean Date Error2 EvalError2 Function1 Math Number1 Object1 RangeError2 ReferenceError2 RegExp3 String1 SyntaxError2 TypeError2 URIError2 1Although defined in ECMA Level 1, was first available in NN3 and IE3/J2 2Defined in ECMA Level 3; implemented in NN6 3Defined in ECMA Level 3; implemented fully in NN4, partially in IE4 JavaScript is loosely typed. Variables, arrays, and function return values are not defined to be of any particular data type. In fact, an initialized variable can hold different data type values in subsequent script statements (obviously not good practice, but possible nonetheless). Similarly, an array may contain values of multiple types. The range of built-in data types is intentionally limited: Boolean (true or false) Null Number (double-precision 64-bit format IEEE 734 value) Object (encompassing the Arrayobject) String Undefined The host environment defines global scope. Web browsers traditionally define a browser window or frame to be the global context for script statements. When a document unloads, all global variables defined by that document are destroyed. JavaScript variables have either global or local scope. A global variable in a Web browser is typically initialized in varstatements that execute as the document loads. All statements in that document can read or write that global variable. A local variable is initialized inside a function (also with the var operator). Only statements inside that function may access that local variable. Scripts sometimes access JavaScript static object properties and methods. Some static objects encourage direct access to their properties or methods. For
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.

57Chapter 13 .JavaScript Essentials NN2 NN3 (Web design templates) NN4 NN6

Thursday, September 13th, 2007

57Chapter 13 .JavaScript Essentials NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . ( ) . . The first four columns represent Navigator versions 2, 3, 4, and 6, respectively (there was no release numbered 5). For Internet Explorer, two columns appear for version 3. One, marked IE3/J1, represents the combination of Internet Explorer 3 and JScript.dll version 1; IE3/J2 represents Internet Explorer 3 and JScript.dll version 2. Internet Explorer 4 and later come with their own JScript.dll versions, so there is no sub-version listed. A checkmark means the feature is compatible with the designated browser. You will also occasionally see one or more of the check- marks surrounded in parentheses. This means some bug or partial implementation for that browser is explained in the body text. Look to the feature s text if there are version issues related to operating system, especially for items that are new with IE4 or later, where many features operate only in Windows. I also recommend that you print the JavaScript and Browser Objects Quick Reference file shown in Appendix A. The file is on the companion CD-ROM in Adobe Acrobat format. This quick reference clearly shows each object s properties, methods, and event handlers, along with keys to the browser version in which each language item is supported. You should find the printout to be valuable as a day-to day resource. Language Essentials for Experienced Programmers In this section, experienced programmers can read the highlights about the core JavaScript language in terms that may not make complete sense to those with lim ited or no scripting experience. This section is especially for you if you found the tutorial of Part II rudimentary. Here, then, is the quick tour of the essential issues surrounding the core JavaScript language. JavaScript is a scripting language. The language is intended for use in an exist ing host environment (for example, a Web browser) that exposes objects whose properties and behaviors are controllable via statements written in the language. Scripts execute within the context of the host environment. The host environment controls what, if any, external environmental objects may be addressed by language statements running in the host environment. For security and privacy reasons, Web browsers generally afford little or no direct access via JavaScript to browser prefer ences, the operating system, or other programs beyond the scope of the browser. The exception to this rule is that modern browsers allow deeper client access (with the user s permission) through trust mechanisms such as signed scripts (Netscape) or trusted ActiveX controls (Microsoft). JavaScript is object-based. Although JavaScript exhibits many syntactic paral lels with the Java language, JavaScript is not as pervasively object-oriented as Java. The core language includes several built-in static objects from which working objects are generated. Objects are created via a call to a constructor function for
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.

56 Part III . Document Objects Reference Figure (Web server version)

Wednesday, September 12th, 2007

56 Part III . Document Objects Reference Figure 13-1 shows the top part of the page. Two important features differentiate this full version from the Jr. version in Chapter 6. Figure 13-1: The Evaluator Sr. First, you can try some Netscape secure features if you have Code Base Principles turned on for your browser (Chapter 46) and you check the Use Code Base Security checkbox (NN4+ only). Second, the page has several HTML elements preinstalled, which you can use to explore DOM properties and methods. As with the smaller version, a set of 26 one-letter global variables (a through z) are initialized and ready for you to assign values for extended evaluation sequences. You should copy the file evaluator.html from the companion CD-ROM to a local hard disk and set a bookmark for it in all of your test browsers. Feel free to add your own elements to the bottom of the page to explore other objects. I describe a version of The Evaluator for embedding in your projects as a debugging tool in Chapter 45. Compatibility ratings in reference chapters With the proliferation of scriptable browser versions since Navigator 2, it is important to know up front whether a particular language or object model object, property, method, or event handler is supported in the lowest common denominator for which you are designing. Therefore, beginning with Chapter 15 of this reference part of the book, I include frequent compatibility charts, such as the following example:
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

55Chapter 13 .JavaScript Essentials IE Browser Version Headaches (Web design tools)

Wednesday, September 12th, 2007

55Chapter 13 .JavaScript Essentials IE Browser Version Headaches As described more fully in the discussion of the navigator object in Chapter 28, your scripts can easily determine which browser is the one running the script. However, the properties that reveal the version don t always tell the whole story about Internet Explorer. For one thing, the Windows and Macintosh versions of the same major browser version (3.0x) implement slightly different object models. The Mac version includes the ever-popular image object for mouse rollover image swapping; the Windows version does not, and any attempt to use such code in the Windows version results in script errors. Next, the first release of Internet Explorer 3 for the Macintosh was not scriptable at all the JavaScript interpreter was left out. Macintosh version 3.01 was the first scriptable Mac version. Even among minor generation releases of Internet Explorer 3 for Windows, Microsoft implemented some new features here and there. Probably the most troublesome problem is that an improved JavaScript interpreter (in the JScript.dll file) underwent substantial improvements between version 1 and version 2 for Windows. Many copies of browser version 3.02 for Windows shipped with version 1 of the .dll. Some users updated their browsers if they knew to download the new .dllfrom Microsoft. Unfortunately, the interpreter version is not reflected in any navigator object property. A nasty Catch-22 in this regard is that version 2 of the interpreter includes a new property that enables you to examine the interpreter version, but testing for that property in a browser that has version 1 of the interpreter installed results in an error message. Due to the insecurity of knowing exactly what will and won t work in a browser that identifies itself as Internet Explorer 3.0x, you might decide to redirect all users of Internet Explorer 3 to pages in your application that include no scripting. But before you think I m bashing Internet Explorer 3, you should also consider doing the same redirection for Navigator 2 users due to the number of platform-specific bugs that littered that first round of JavaScript. Object model and core language implementations in NN3+ and IE4+ are much more stable and reliable platforms on which to build scriptable applications (and you get genuine array objects!). If you have an opportunity to study the access logs of your Web site, analyze the proportion of different browser versions over several days before deciding where you set your lowest common denominator for scripted access. Even with IE5, browser detection remains a challenge. As you can see in detail in Chapter 28, the navigator.appVersion property for IE5 for Windows reports version 4 (the same as IE4). You can still sniff for version 5 (you can find the designation MSIE 5 in the navigator.userAgentproperty), but the process is not as straightforward as it could be especially if you need to look for any version greater than or equal to 5. The best advice is to be vigilant when new browsers come on the scene or adopt object detection techniques in your scripts.
We recommend high quality webhost to host and run your jsp application: christian web host services.

54 Part III . Document Objects Reference Another (Web design service)

Wednesday, September 12th, 2007

54 Part III . Document Objects Reference Another possibility is to make a portion of the site accessible to most, if not all, browsers, and restrict the scripting to only the occasional enhancement that non- scriptable browser users won t miss. Once the application reaches a certain point in the navigation flow, then the user needs a more capable browser to get to the really good stuff. This kind of design is a carefully planned strategy that lets the site welcome all users up to a point, but then enables the application to shine for users of, say, W3C DOM-compatible browsers. The ideal page is one that displays useful content on any browser, but whose scripting enhances the experience of the page visitor perhaps by offering more efficient site navigation or interactivity with the page s content. That is certainly a worthy goal to aspire to. But even if you can achieve this ideal on only some pages, you will reduce the need for defining entirely separate, difficult-to-maintain paths for browsers of varying capabilities. Dealing with beta browsers If you have crafted a skillfully scripted Web page or site, you may be concerned when a prerelease (or beta) version of a browser available to the public causes script errors or other compatibility problems to appear on your page. Do yourself a favor don t overreact to bugs and errors that occur in prerelease browser ver sions. If your code is well written, it should work with any new generation of browser. If the code doesn t work correctly, consider the browser to be buggy. Report the bug (preferably with a simplified test case script sample) to the browser maker. The exception to the it s a beta bug rule arose in the transition from NN4 to NN6. As you learn in Chapter 14, a conscious effort to eliminate a proprietary NN4 feature (the tag and corresponding scriptable object) caused many NN4 scripts to break on NN6 betas (and final release). Had scripters gone to report the problem to the new browsers developer (Mozilla), they would have learned of the policy change, and planned for the new implementation. It is extremely rare for a browser to eliminate a popular feature so quickly, but it can happen. It is often difficult to prevent yourself from getting caught up in browser makers enthusiasm for a new release. But remember that a prerelease version is not a ship ping version. Users who visit your page with prerelease browsers should know that there may be bugs in the browser. That your code does not work with a prerelease version is not a sin, nor is it worth losing sleep over. Just be sure to connect with the browser s maker either to find out if the problem will continue in the final release or to report the bug so the problem doesn t make it into the release version. The Evaluator Sr. In Chapter 6, you were introduced to a slimmed-down version of The Evaluator Jr., which provides an interactive workbench to experiment with expression evalua tion and object inspection. At this point, you should meet The Evaluator Sr., a tool you will use in many succeeding chapters to help you learn both core JavaScript and DOM terminology.
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

53Chapter 13 .JavaScript Essentials the error, you can (My space web page)

Tuesday, September 11th, 2007

53Chapter 13 .JavaScript Essentials the error, you can cascade the conditional tests with the help of the && operator. The following fragment tests for the existence of both the document.bodyobject and the document.body.styleproperty: if (document.body && document.body.style) { // statements that work on the body s style property } If the test for document.body fails, JavaScript bypasses the second test. One potential gotcha to using conditional expressions to test for the existence of an object s property is that even if the property exists but its value is zero or an empty string, the conditional test reports that the property does not exist. To workaround this potential problem, the conditional expression can examine the data type of the value to ensure that the property genuinely exists. A non-existent property for an object reports a data type of undefined. Use the typeofoperator (Chapter 40) to test for a valid property: if (document.body && typeof document.body.scroll != undefined ) { // statements that work on the body s scroll property } Object detection is the wave of the future, and I wholeheartedly recommend designing your scripts to take advantage of it in lieu of branching on particular browser name strings and version numbers. Scriptable features are gradually find ing their way into browsers embedded in a wide range of non-traditional computing devices. These browsers may not go by the same names and numbering systems that we know today, yet such browsers may be able to interpret your scripts. By testing for browser functionality, your scripts will likely require less maintenance in the future. You can see more object detection at work in Chapters 47 and 56. Designing for Compatibility Each new major release of a browser brings compatibility problems for page authors. It s not so much that old scripts break in the new versions (well-written scripts rarely break in new versions with the rare exception of the jump from NN4 to NN6). No, the problems center on the new features that attract designers when the designers forget to accommodate visitors who have not advanced to the latest and greatest browser version yet or who don t share your browser brand preference. Adding to these problems are numerous bugs, particularly in first-generation browsers from both Netscape and Microsoft. Worse still, some of these bugs affect only one operating system platform among the many supported by the browser. Even if you have access to all the browsers for testing, the process of finding the errors, tracking down the bugs, and implementing workarounds that won t break later browsers can be quite frustrating even when you ve scripted pages from the earliest days and have a long memory for ancient bug reports. Catering only to the lowest common denominator can more than double your development time due to the expanded testing matrix necessary to ensure a good working page in all operating systems and on all versions. Decide how important the scripted functionality you employ in a page is for every user. If you want some functionality that works only in a later browser, then you may have to be a bit auto cratic in defining the minimum browser for scripted access to your page any lesser browser gets shunted to a simpler presentation of your site s data.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.