Detecting Features with jQuery.support - J Query

Problem
You need to attach a special click handler to all anchor tags that have just a hash for the current page, and you don’t want to risk it breaking because of browser support issues.

Solution

Discussion
The jQuery.support object was added in version 1.3 and contains Boolean flags to help write code using browser feature detection. In our example, Internet Explorer (IE) has a different behavior in how it handles the href attribute. IE will return the full URL instead of the exact href attribute. Using the href Normalized attribute, we have future proofed our solution in the event that a later version of IE changes this behavior. Otherwise,we would have needed a conditional that contained specific browser versions.While it may be tempting, it is best to avoid this approach because it requires future maintenance as new versions of browsers are released. Another reason to avoid targeting specific browsers is that it is possible for clients to intentionally or un intentionally report an incorrect user agent string. In addition to the href Normalized attribute, a number of additional attributes exist:

boxModel
True if the browser renders according to the W3C CSS box model specification
cssFloat
True if style.cssFloatis used to get the current CSS float value
hrefNormalized
True if the browser leaves intact the results from get Attribute('href')
htmlSerialize
True if the browser properly serializes link elements with the inner HTML attribute
leadingWhitespace
True if the browser preserves leading whitespace when inner HTML is used
noCloneEvent
True if the browser does not clone event handlers when elements are cloned
objectAll
True if getElementsByTagName('*') on an element returns all descendant elements
opacity
True if the browser can interpret the CSS opacity style
scriptEval
True if using appendChildfor a <script>tag will execute the script
style
True if getAttribute('style') is able to return the inline style specified by an element
tbody
True if the browser allows <table>elements without a <tbody>element


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

J Query Topics