Test

Page 295

HTML <p> </p>

Example 2:

Returns false if the page is in Quirks Mode in Internet Explorer

Javascript $.boxModel

Results false

jQuery.support A collection of properties that represent the presence of different browser features or bugs. Added in version 1.3

Rather than using $.browser to detect the current user agent and alter the page presentation based on which browser is running, it is a good practice to perform feature detection. This means that prior to executing code which relies on a browser feature, we test to ensure that the feature works properly. To make this process simpler, jQuery performs many such tests and makes the results available to us as properties of the jQuery.support object. The values of all the support properties are determined using feature detection (and do not use any form of browser sniffing). Following are a few resources that explain how feature detection works: http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting http://www.jibbering.com/faq/faq_notes/not_browser_detect.html http://yura.thinkweb2.com/cft/ While jQuery includes a number of properties, developers should feel free to add their own as their needs dictate. Many of the jQuery.support properties are rather low-level, so they are most useful for plugin and jQuery core development, rather than general day-to-day development. Since jQuery requires these tests internally, they must be performed on every page load; for that reason this list is kept short and limited to features needed by jQuery itself. The tests included in jQuery.support are as follows: is equal to true if a browser is able to create an XMLHttpRequest object. is equal to true if the page is rendering according to the W3C CSS Box Model (is currently false in IE 6 and 7 when they are in Quirks Mode). This property is null until document ready occurs. changeBubbles is equal to true if the change event bubbles up the DOM tree, as required by the W3C DOM event model. (It is currently false in IE, and jQuery simulates bubbling). checkClone is equal to true if a browser correctly clones the checked state of radio buttons or checkboxes in document fragments. checkOn is equal to true if the value of a checkbox defaults to "on" when no value is specified. cors is equal to true if a browser can create an XMLHttpRequest object and if that XMLHttpRequest object has a withCredentials property. To enable cross-domain requests in environments that do not support cors yet but do allow cross-domain XHR requests (windows gadget, etc), set $.support.cors = true;. CORS WD cssFloat is equal to true if the name of the property containing the CSS float value is .cssFloat, as defined in the CSS Spec. (It is currently false in IE, it uses styleFloat instead). hrefNormalized is equal to true if the .getAttribute() method retrieves the href attribute of elements unchanged, rather than normalizing it to a fully-qualified URL. (It is currently false in IE, the URLs are normalized). DOM l3 spec htmlSerialize is equal to true if the browser is able to serialize/insert <link> elements using the .innerHTML property of elements. (is currently false in IE). HTML5 WD leadingWhitespace is equal to true if the browser inserts content with .innerHTML exactly as provided—specifically, if leading whitespace characters are preserved. (It is currently false in IE 6-8). HTML5 WD noCloneChecked is equal to true if cloned DOM elements copy over the state of the .checked expando. (It is currently false in IE). (Added in jQuery 1.5.1) noCloneEvent is equal to true if cloned DOM elements are created without event handlers (that is, if the event handlers on the source element are not cloned). (It is currently false in IE). DOM l2 spec opacity is equal to true if a browser can properly interpret the opacity style property. (It is currently false in IE, it uses alpha filters instead). ajax

boxModel


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.