Archive for November, 2007

Web design seattle - JavaScript Programmer’s Reference break; case “NO” : //

Friday, November 9th, 2007

JavaScript Programmer’s Reference break; case “NO” : // Fall back to the legacy browser, no layers page break; default: // Unexpected condition handled here break; } Because we need to know what browser and version the code is being run on to determine simulation capabilities, those get set as member properties of the isAvailable object. Later you could add capabilities to access the DOM feature-detection mechanisms so that all these related feature-detection facilities are in a single reusable code block. Note that the appVersion value picks up the Mozilla/X.YY value and uses that. This means that MSIE 5 reports an appVersion of 4 and Netscape version 6.0 reports an appVersion of 5, which is odd to say the least. You can do a bit more work to parse out the correct version numbers from the remainder of the user agent string or access special values that are platform dependant within a fragment of code that is selected on a per platform basis. Example code: See also: Boolean object,Boolean. constructor,Boolean.toSource(), Boolean.toString(), Boolean.valueOf(), prototype property, Boolean.prototype Cross-references: ECMA 262 edition 2 section 15.2.3.1 ECMA 262 edition 2 section 15.6.3.1 ECMA 262 edition 3 section 15.6.3.1 Boolean.toSource() (Method) Returns a Boolean object formatted as a Boolean literal contained in a string. JavaScript 1.3 Netscape 4.06 Opera 3.0 Availability: Property/method value type: JavaScript syntax: String primitive myBoolean.toSource() N This is an alternative way to retrieve a string version of a Boolean value. In this case, it is formatted as a Boolean literal and can then be used in an eval() function to assign another Boolean. If you run the example below, it should yield this as a result: (new Boolean(true)) However, you should note that this is not supported by MSIE browsers. The result of calling this method is a string version of the Boolean formatted as a Boolean literal. Example code: // Create a boolean and then examine its source myBoolean = new Boolean(true); document.write(myBoolean.toSource()); See also: Boolean.prototype, Boolean.toString()

JavaScript Programmer’s Reference Cross-references: ECMA 262 edition 2

Saturday, November 3rd, 2007

JavaScript Programmer’s Reference Cross-references: ECMA 262 edition 2 section 15.6.1 ECMA 262 edition 2 section 15.6.2 ECMA 262 edition 2 section 15.6.3 ECMA 262 edition 3 section 15.6.2 Boolean.prototype (Property) The prototype for the Booleanobject that can be used to extend the interface for all Boolean objects. Availability: ECMAScript edition 2 JavaScript 1.1 JScript 3.0 Internet Explorer 4.0 Netscape 3.0 Netscape Enterprise Server 2.0 Opera 3.0 Property/method value type: Boolean object -Boolean.prototype JavaScript syntax: -myBoolean.constructor.prototype The initial value of the prototype of a Boolean object is the built-in Boolean prototype object. The example demonstrates how to provide extensions to all instances of this class by adding a function to the prototype object. Example code: