Archive for December, 2007

Web design portfolio - 351Chapter 18 .The Document and Body Objects named

Monday, December 31st, 2007

351Chapter 18 .The Document and Body Objects named cookie entries for any domain; IE3 imposes an even more restrictive limit of one cookie (that is, one name/value pair) per domain. If your cookie requirements are extensive, then you need to fashion ways of concatenating cookie data (I do this in the Decision Helper application in Chapter 55). Saving cookies To write cookie data to the cookie file, you use a simple JavaScript assignment operator with the document.cookieproperty. But the formatting of the data is crucial to achieving success. Here is the syntax for assigning a value to a cookie (optional items are in brackets): document.cookie = cookieName=cookieData [; expires=timeInGMTString] [; path=pathName] [; domain=domainName] [; secure] Examine each of the properties individually. Name/Data Each cookie must have a name and a string value (even if that value is an empty string). Such name/value pairs are fairly common in HTML, but they look odd in an assignment statement. For example, if you want to save the string Fred to a cookie named userName, the JavaScript statement is document.cookie = userName=Fred If the browser sees no existing cookie in the current domain with this name, it automatically creates the cookie entry for you; if the named cookie already exists, the browser replaces the old data with the new data. Retrieving document.cookie at this point yields the following string: userName=Fred You can omit all the other cookie-setting properties, in which case the browser uses default values, as explained in a following section. For temporary cookies (those that don t have to persist beyond the current browser session), the name/value pair is usually all you need. The entire name/value pair must be a single string with no semicolons, commas, or character spaces. To take care of spaces between words, preprocess the value with the JavaScript escape() function, which URL-encodes the spaces as %20(and then be sure to unescape() the value to restore the human-readable spaces when you retrieve the cookie later). You cannot save a JavaScript array or object to a cookie. But with the help of the Array.join() method, you can convert an array to a string; use String.split() to re-create the array after reading the cookie at a later time. These two methods are available in NN3+ and IE4+. Expires Expiration dates, when supplied, must be passed as Greenwich Mean Time (GMT) strings (see Chapter 36 about time data). To calculate an expiration date based on today s date, use the JavaScript Date object as follows: document.cookie
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Web hosting india - 350 Part III . Document Objects Reference A

Sunday, December 30th, 2007

350 Part III . Document Objects Reference A cookie record Among the fields of each cookie record are the following (not necessarily in this order): . Domain of the server that created the cookie . Information on whether you need a secure HTTP connection to access the cookie . Pathname of URL(s) capable of accessing the cookie . Expiration date of the cookie . Name of the cookie entry . String data associated with the cookie entry Notice that cookies are domain-specific. In other words, if one domain creates a cookie, another domain cannot access it through the browser s cookie mechanism behind your back. That reason is why it s generally safe to store what I call throw away passwords (the username/password pairs required to access some free registration-required sites) in cookies. Moreover, sites that store passwords in a cookie usually do so as encrypted strings, making it more difficult for someone to hijack the cookie file from your unattended PC and figure out what your personal password scheme may be. Cookies also have expiration dates. Because some browsers may allow no more than a fixed number of cookies (300 in NN), the cookie file can get pretty full over the years. Therefore, if a cookie needs to persist past the current browser session, it should have an expiration date established by the cookie writer. Browsers auto matically clean out any expired cookies. Not all cookies have to last beyond the current session, however. In fact, a sce nario in which you use cookies temporarily while working your way through a Web site is quite typical. Many shopping sites employ one or more temporary cookie records to behave as the shopping cart for recording items you intend to purchase. These items are copied to the order form at checkout time. But after you submit the order form to the server, that client-side data has no particular value. As it turns out, if your script does not specify an expiration date, the browser keeps the cookie fresh in memory without writing it to the cookie file. When you quit the browser, that cookie data disappears as expected. JavaScript access Scripted access of cookies from JavaScript is limited to setting the cookie (with a number of optional parameters) and getting the cookie data (but with none of the parameters). The original object model defines cookies as properties of documents, but this description is somewhat misleading. If you use the default path to set a cookie (that is, the current directory of the document whose script sets the cookie in the first place), then all documents in that same server directory have read and write access to the cookie. A benefit of this arrangement is that if you have a scripted application that contains multiple documents, all documents served from the same directory can share the cookie data. NN and IE, however, impose a limit of 20 document.cookie
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

349Chapter 18 .The Document and Body Objects Other (Web hosting colocation)

Sunday, December 30th, 2007

349Chapter 18 .The Document and Body Objects Other applications of the cookie include storing user preferences and information about the user s previous visit to the site. Preferences may include font styles or sizes and whether the user prefers viewing content inside a frameset or not. As shown in Chapter 54, a time stamp of the previous visit can allow a coded HTML page to display highlighted images next to content that has changed since the user s last visit, even if you have updated the page several times in the interim. Rather than hard-wiring New flags for your last visit, the scripts highlight what s new for the visitor. Note I cover the technical differences between Navigator and Internet Explorer cookies later in this section. But for IE3, be aware that the browser neither reads nor writes cookies when the document accessing the cookie is on the local hard disk. IE4+ works with cookies generated by local files. The cookie file Allowing some foreign CGI program to read from and write to your hard disk may give you pause, but browser cookie mechanisms don t just open up your drive s directory for the world to see (or corrupt). Instead, the cookie mechanism provides access to just one special text file (Navigator) or type of text file (Internet Explorer) located in a platform-specific spot on your drive. In Windows versions of Navigator 4, for example, the cookie file is named cookies.txt and is located in a directory reserved for a user s Navigator preferences; Mac users can find the MagicCookiefile inside the Netscape folder, which is located within the System Folder:Preferences folder. Internet Explorer for Windows uses a different filing system: all cookies for each domain saved in a domain-specific file inside a Cookies directory within system directories. File names include the user name and domain of the server that wrote the cookie. A cookie file is a text file (but because NN s Macintosh MagicCookie file s type is not TEXT, Mac users can open it only via applications capable of opening any kind of file). If curiosity drives you to open a cookie file, I recommend you do so only with a copy saved in another directory or folder. Any alteration to the existing file can mess up whatever valuable cookies are stored there for sites you regularly visit. The data format for NN and IE differs, in line with the different methodologies used for filing cookies. Inside the Netscape file (after a few comment lines warning you not to manually alter the file) are lines of tab-delimited text. Each return-delimited line contains one cookie s information. The cookie file is just like a text listing of a database. In each of the IE cookie files, the same data points are stored for a cookie as for Navigator, but the items are in a return-delimited list. The structure of these files is of no importance to scripting cookies, because both browsers utilize the same syntax for reading and writing cookies through the document.cookieproperty. Note As you experiment with browser s cookies, you will be tempted to look into the cookie file after a script writes some data to the cookie. The cookie file will not contain the newly written data, because cookies are transferred to disk only when the user quits the browser; conversely, the cookie file is read into the browser s memory when it is launched. While you read, write, and delete cookies during a browser session, all activity is performed in memory (to speed up the process) to be saved later. document.cookie
You want to have a cheap webhost for your apache application, then check apache web hosting services.

My space web page - 348 Part III . Document Objects Reference characterSet

Saturday, December 29th, 2007

348 Part III . Document Objects Reference characterSet Value: String Read/Write Compatibility NN2 NN3 NN4 NN6 . IE3/J1 IE3/J2 IE4 IE5 IE5.5 The characterSet property reveals the character set used by the browser to render the current document (the IE4+ version of this property is called charset). You can find possible values for this property at ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets Each browser and operating system has its own default character set. Values may also be set via a tag. On the Example on the CD CD-ROM Related Items: charset property. cookie Value: String Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . The cookie mechanism in a Web browser lets you store small pieces of information on the client computer in a reasonably secure manner. In other words, when you need some tidbit of information to persist at the client level while either loading diverse HTML documents or moving from one session to another, the cookie mechanism saves the day. You can find Netscape s technical documentation (much of which is written from the perspective of a server writing to a cookie) on the Web at http://www.netscape.com/newsref/std/cookie_spec.html. The cookie is commonly used as a means to store the username and password you enter into a password-protected Web site. The first time you enter this information into a CGI-governed form, the CGI program has Navigator write the information back to a cookie on your hard disk (usually after encrypting the password). Rather than bothering you to enter the username and password the next time you access the site, the server searches the cookie data stored for that particular server and extracts the username and password for automatic validation processing behind the scenes. document.cookie
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

347Chapter 18 .The Document (Web server logs) and Body Objects body

Saturday, December 29th, 2007

347Chapter 18 .The Document and Body Objects body Value: BODY Element Object Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . The document.body property is a shortcut reference to the BODY element object in modern object models. As you can see in the discussion of the BODY element object later in this chapter, that object has many key properties that govern the look of the entire page. Because the documentobject is the root of all references within any window or frame, the document.body property is easier to use to get to the BODY properties, rather than longer references normally used to access HTML element objects in both the IE4+ and W3C object models. On the Example on the CD CD-ROM Related Items: BODY element object. charset Value: String Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . The charset property reveals the character set used by the browser to render the current document (the NN6 version of this property is called characterSet). You can find possible values for this property at ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets Each browser and operating system has its own default character set. Values may also be set via a tag. On the Example on the CD CD-ROM Related Items: characterSet, defaultCharset properties. document.charset
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Web site templates - 346 Part III . Document Objects Reference delivers

Friday, December 28th, 2007

346 Part III . Document Objects Reference delivers an indexed array of anchors in a document. Use the array references to pinpoint a specific anchor for retrieving any anchor property. Anchor arrays begin their index counts with 0: The first anchor in a document, then, has the reference document.anchors[0]. And, as is true with any built-in array object, you can find out how many entries the array has by checking the length property. For example var anchorCount = document.anchors.length The document.anchors property is read-only. To script navigation to a particu lar anchor, assign a value to the window.locationor window.location.hash object, as described in Chapter 17 s location object discussion. On the CD-ROM Example on the CD with Listing 18-2 Related Items: anchor, location objects; document.links property. applets Value: Array of applet objects Read-Only NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . The applets property refers to Java applets defined in a document by the tag. An applet is not officially an object in the document until the applet loads completely. Most of the work you do with Java applets from JavaScript takes place via the methods and variables defined inside the applet. Although you can reference an applet according to its indexed array position within the appletsarray, you will more likely use the applet object s name in the reference to avoid any confusion. Note that applets are not accessible to JavaScript in IE/Mac. For more details, see the discussion of the applet object in Chapter 32 and the LiveConnect discussion in Chapter 44. On the CD-ROM Example on the CD Related Items: applet object. bgColor See alinkColor document.bgColor
You want to have a cheap webhost for your apache application, then check apache web hosting services.

345Chapter 18 .The Document and Body Objects (X web hosting) Table

Friday, December 28th, 2007

345Chapter 18 .The Document and Body Objects Table 18-1 Setting Document Colors on the Fly (Browser Versions) Navigator Internet Explorer Color Property bgColor All others Windows Mac All 4+ 6 6 UNIX Windows Mac UNIX 4+ All All 4+ 6 All All 4+ If you experiment with setting document.bgColor on Mac or UNIX versions of Navigator 2 and 3, you may be fooled into thinking that the property is being set correctly. While the property value may stick, these platforms do not refresh their windows properly: If you change the color after all content is rendered, the swath of new color obscures the content until a reload of the window. The safest, backward- compatible scripted way of setting document color properties is to compose the content of a frame or window by script and set the tag color attributes dynamically when document.write()puts the content into the window. Values for all color properties can be either the common HTML hexadecimal triplet value (for example, #00FF00 ) or any of the Netscape color names. Internet Explorer recognizes these plain language color names, as well. But also be aware that some colors work only when the user has the monitor set to 16- or 24-bit color settings. If you are scripting exclusively for IE4+ and NN6, you should use the document. body object to access these properties. On the Example on the CD with Listing 18-1 CD-ROM Related Items: body.aLink, body.bgColor, body.link, body.text, body.vLink properties. anchors Value: Array of anchor objects Read-Only NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . Anchor objects (described in Chapter 21) are points in an HTML document marked with tags. Anchor objects are referenced in URLs by a hash value between the page URL and anchor name. Like other object properties that contain a list of nested objects, the document.anchors property (notice the plural) document.anchors
Searching for affordable and reliable webhost to host and run your web applications? Go to our
java web server services and you will be pleased.

344 Part III . (Web design portfolio) Document Objects Reference Properties

Friday, December 28th, 2007

344 Part III . Document Objects Reference Properties activeElement Value: Object Reference Read-Only Compatibility NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 . IE5 . IE5.5 . In IE4+, a script can examine the document.activeElementproperty to see which element currently has focus. The value returned is an element object reference. You can use any of the properties and methods listed in Chapter 15 to find out more about the object. Be aware that not all elements in all operating systems receive focus. For example, buttons in IE4 for the Macintosh do not receive focus. Although the element used to generate a mouse or keyboard event will most likely have focus (except for IE4/Mac buttons), don t rely on the activeElement property to find out which element generated an event. The IE event.srcElement property is far more reliable. On the Example on the CD CD-ROM Related Items: event.srcElement property. alinkColor bgColor fgColor linkColor vlinkColor Value: Hexadecimal triplet or color name string Mostly Read/Write NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . These five properties are the script equivalent of the tag attributes of the same name (although the property names are case-sensitive). All five settings can be read via scripting, but the ability to change some or all of these properties varies widely with browser and client platform. Table 18-1 shows a summary of which browsers and platforms can set which of the color properties. document.alinkColor
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

343Chapter 18 .The Document and Body Objects served

Thursday, December 27th, 2007

343Chapter 18 .The Document and Body Objects served as an HTML container for forms, links, and anchors. The document object, therefore, assumed a majority of the role of the BODY element. But even then, the document object became the most convenient place to bind some properties that extend beyond the BODY element, such as the TITLE element and the URL of the link that referred the user to the page. When viewed within the context of the HTML source code, the original document object is somewhat schizophrenic. Even so, the document object has worked well as the basis for references to original object model objects, such as forms, images, and applets. This, of course, was before every HTML element, including the BODY element, was exposed as an object via modern object models. Amazingly, even with the IE4+ object model and W3C DOM both of which treat the BODY element as an object separate from the documentobject script compatibility with the original object model is quite easily accomplished. The document object has assumed a new schizophrenia, splitting its personality between the original object model and the one that places the document object at the root of the hierarchy, quite separate from the BODY element object it contains. The object knows which face to put on based on the rest of the script syntax that follows it. This means that quite often there are multiple ways to achieve the same reference. For example, you can use the following statement in all scriptable browsers to get the number of form objects in a document: document.forms.length In IE4+, you can also use document.tags[ FORM ].length And in the W3C DOM as implemented in IE5+ and NN6, you can use document.getElementsByTagName( FORM ).length The more modern versions provide generic ways of accessing elements (the tags array in IE4+ and the getElementsByTagName()method in the W3C DOM) to meet the requirements of object models that expose every HTML (and XML) element as an object. Promoting the BODY element to the ranks of exposed objects presented its own challenges to the new object model designers. The BODY element is the true owner of some properties that the original document object had to take on by default. Most properties that had belonged to the original document object were renamed in their transfer to the BODY element. For example, the original document.alinkColor property is the body.aLinkproperty in the new model. But the bgColorproperty has not been renamed. For the sake of code compatibility, the current versions of browsers recognize both properties, even though the W3C DOM (in an effort to push the development world ahead) has removed the old versions as properties of what it conceives as the document object. As confusing as all of this may sound on the surface, understanding when to refer to the original document object and when to use the new syntax doesn t take long. It all depends on what you hang off the right edge of the reference. Original properties and methods are recognized as using the original document object; new properties and methods summon the powers of the new document object. It s all quite automatic. Thankfully. document
You want to have a cheap webhost for your apache application, then check apache web hosting services.

342 Part III . Document Objects (Web site builder) Reference Properties

Thursday, December 27th, 2007

342 Part III . Document Objects Reference Properties Methods Event Handlers parentWindow plugins previousSibling protocol readyState referrer scripts security selection styleSheets tags title uniqueID URL URLUnencoded VlinkColor width See Chapter 15. Syntax Accessing documentobject properties or methods: [window.]document.property | method([parameters]) About this object A document object encompasses the totality of what exists inside the content region of a browser window or window frame (excluding toolbars, status lines, and so on). The document is a combination of the content and interface elements that make the Web page worth visiting. In more recent browsers, which treat HTML elements as nodes of a hierarchical tree, the document object is the root node that from which all other nodes grow. Because the documentobject isn t explicitly represented in an HTML document by tags or any other notation, the original designers of JavaScript and object models decided to make the document object the portal to many settings that were represented in HTML as belonging to the BODY element. That element s tag contains attributes for document-wide attributes, such as background color (BGCOLOR) and link colors in various states (ALINK, LINK, and VLINK). The BODY element also document
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.