http://api.jquery.com/jQuery.support/
jQuery.support Returns: Object .
Description: A collection of properties that represent the presence of different browser features or bugs. Primarily intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance.
version added: 1.3jQuery.support
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 use feature detection. To make this process simpler, jQuery performs many such tests and sets properties of the jQuery.support object.
Since jQuery requires these tests internally, they must be performed on every page load. Although some of these properties are documented below, they are not subject to a long deprecation/removal cycle and may be removed once internal jQuery code no longer needs them.
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/
For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support.
The tests included in jQuery.support are as follows:
• ajax is equal to true if a browser is able to create an XMLHttpRequest object.
• boxModel 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).
CSS3 spec
• optDisabled is equal to true if option elements within disabled select elements are not automatically marked as disabled.
HTML5 WD
• optSelected is equal to true if an <option> element that is selected by default has a working selected property.
HTML5 WD
• scriptEval() is equal to true if inline scripts are automatically evaluated and executed when inserted into the document using standard DOM manipulation methods such as .appendChild() and .createTextNode(). (It is currently false in IE, it uses .text to insert executable scripts).
Note: No longer supported; removed in jQuery 1.6. Prior to jQuery 1.5.1, the scriptEval() method was the static scriptEval property. The change to a method allowed the test to be deferred until first use to prevent content security policy inline-script violations.
HTML5 WD
• style is equal to true if inline styles for an element can be accessed through the DOM attribute called style, as required by the DOM Level 2 specification. In this case, .getAttribute('style') can retrieve this value; in Internet Explorer, .cssText is used for this purpose.
DOM l2 Style spec
• submitBubbles is equal to true if the submit event bubbles up the DOM tree, as required by the W3C DOM event model. (It is currently false in IE, and jQuery simulates bubbling).
• tbody is equal to true if an empty <table> element can exist without a <tbody> element. According to the HTML specification, this sub-element is optional, so the property should be true in a fully-compliant browser. If false, we must account for the possibility of the browser injecting <tbody> tags implicitly. (It is currently false in IE, which automatically inserts tbody if it is not present in a string assigned to innerHTML).
HTML5 spec
Examples:
Example: Returns the box model for the iframe.
<!DOCTYPE html><html><head> <style> p { color:blue; margin:20px; } span { color:red; } </style> <script src="http://code.jquery.com/jquery-latest.js"></script></head><body> <p> </p><script> $("p").html("This frame uses the W3C box model: <span>" + jQuery.support.boxModel + "</span>");</script></body></html>
Demo:
Example: Returns false if the page is in QuirksMode in Internet Explorer
jQuery.support.boxModel
Result:
false
分享到:
相关推荐
jquery1.9.1 支持低版本ajax (ajax前jQuery.support.cors=true )
例如,`jQuery.support.ajax` 可以检查浏览器是否支持XMLHttpRequest(即AJAX)操作,`jQuery.support.cssTransitions` 检测CSS3过渡效果的可用性。这些属性的值通常为`true`或`false`,表示特性在当前浏览器中是否...
Implements automatic *Cross Origin Resource Sharing* support using the `XDomainRequest` object for IE8 and IE9 when using the [$.ajax](http://api.jquery.com/jQuery.ajax/) function in jQuery 1.5+. ...
script src =" dist/jquery.support.css3.min.js " > </ script > < script > jQuery ( function ( $ ) { if ( $ . support . transition ) { $ ( Selector ) . on ( $ . support . transition ....
### jQuery 源码分析:深入理解jQuery.support 在前端开发中,浏览器兼容性问题是一个长期存在的挑战。随着互联网的快速发展,各种不同的浏览器层出不穷,每种浏览器都有自己的特性和Bug。为了帮助开发者屏蔽这些...
它可能包括使用`jQuery.support`来检测浏览器特性,以及对CSS3动画的降级处理,以确保在不支持这些特性的浏览器中也能实现平滑的过渡效果。 此外,模态窗口的样式可以通过自定义CSS来进一步调整,以满足项目的视觉...
jQuery.support对象用于返回当前浏览器的特性和bug信息,便于开发者进行浏览器兼容性检测。 在数组操作方面,jQuery.extend()和jQuery.fn.extend()函数用于合并对象,jQuery.grep()用于根据过滤函数来过滤数组元素...
这个插件/仓库正在寻找维护者。 如果您有兴趣,请发送电子邮件至 。... script src =" //cdn.jsdelivr.net/npm/jquery.marquee@1.5.0/jquery.marquee.min.js " type =" text/javascript " > </ script >
// @hack by liqt:support for inputing chinese characters in firefox onChange(0, true); }); }); ``` 这样修改后,当 Firefox 中的输入字段内容发生变化时,会调用内部的 `onChange` 函数,从而实现在输入...
// @hack by liqt:support for inputing chinese characters in firefox }); ``` 这段代码会监听 "oninput" 事件,当输入框的中文字符发生变化时,重新执行查询操作,从而解决了 Firefox 中的中文输入匹配问题,...
前端项目-jquery.iframe-transport,jQuery plugin that implements an iframe transport so that ajax calls support the uploading of files using standard HTML file input fields
1.8系列引入了重要的$.support对象,用于检测浏览器特性,还优化了$.each方法,提升了性能。尽管这个版本可能不包含最新的功能,但它对早期浏览器的支持和较小的体积,使其在某些情况下仍然是一个不错的选择,特别是...
同样,检测是否为IE6-8,可以使用`$.support.leadingWhitespace`,因为IE6-8不支持这个CSS属性: ```javascript if (!$.support.leadingWhitespace) { // ... } ``` 虽然这些转换可以帮助你在不使用`$.browser`的...
objjQuery.support objjQuery.browserdeprecated strjQuery.browser.versiondeprecated booljQuery.boxModeldeprecated Basic operations objjQuery.each( obj, fn( index, valueOfElement ) ) objjQuery.extend( ...
$.browser是通过正则表达式来匹配userAgent来判断浏览器版本和种类的.jquery1.3.2版本的文档中已经声明jquery.browser及jquery.browser.version建议弃用,可以使用jquery.support来代替。 jQuery 从 1.9 版开始,...
+ jQuery.support.scriptEval + 原 Dimension 插件功能(1.2.6版加入jQuery核心) 2009-01-16 19:11:10 +0800 + jQuery.fx.off + toggleClass( class, switch ) + toggle( switch ) + toggle(speed,[callback]) * ...
+ jQuery.support.scriptEval + 原 Dimension 插件功能(1.2.6版加入jQuery核心) 2009-01-16 19:11:10 +0800 + jQuery.fx.off + toggleClass( class, switch ) + toggle( switch ) + toggle(speed,[callback]) * ...
开发者可以使用`jQuery.support`属性来检查浏览器对特定HTML或CSS特性的支持,或者使用第三方库Modernizr,这是一个功能强大的工具,能检测浏览器对现代Web技术的支持情况。 3. jQuery 选择器 jQuery 的选择器是其...
例如,`$.browser`对象已被移除,鼓励开发者使用`$.support`或现代浏览器检测方法。 3. **性能提升**:jQuery2.0.0在选择器引擎、DOM操作和动画效果等方面进行了优化,提升了执行效率。特别是对于大型DOM操作,性能...