1264 Part V . Putting JavaScript to Work (Cheap web hosting)
1264 Part V . Putting JavaScript to Work Platform equivalency Another technique attempts to limit the concern for the different ways each platform refers to a positionable element (because cross-browser DHTML is pretty much limited to the properties affecting positionable elements). If you examine the formats for each platform s object references, you see that all formats contain a reference to the document and to the object name or ID. The IE4+ DOM syntax also includes property words, such as all and style. If you assign these extra property names to variables for IE4 and leave those variables as empty strings for NN4, you can assemble an object reference for those two platforms in one statement. To begin using this technique, set two global variables that store reference components for the scope (allin IE4) and the style object (style in IE4): var range = var styleObj = if (parseInt(navigator.appVersion) == 4) { if (navigator.appVersion.indexOf( MSIE ) != -1) { range = all. styleObj = .style } } From this point, you can assemble an object reference with the help of the JavaScript eval()function, as follows: var instrux = eval( document. + range + instructions + styleObj) instrux.visibility = hidden Or, you can use the eval() function to handle the entire property assignment in one statement, as follows: eval( document. + range + instructions + styleObj + .visibility = hidden ) If your page does not have a lot of objects that your scripts will be adjusting, you can use this platform equivalency approach to create global variables holding references to your positionable objects at load time (triggered by the onLoadevent handler so that all objects exist and can be referenced by the eval()function). Then, use those variables for object references throughout the scripts. Unfortunately, the platform equivalency methodology breaks down when a NN4 layer object is nested inside another layer. The platform equivalency formulas assume that each object is directly addressable from the outermost document object. If your objects have a variety of nested locations, you can use either the inline branching method described earlier, or batch-assign objects to global variables at load time using platform branching techniques along the lines of the following example: var instrux function initObjectVars() { if (isNav4) { instrux = document.outerLayer.document.instructions } else { instrux = document.all.instructions.style } }
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.