问题
I've seen plenty of examples for detecting support for border radius using something like:
var cssAttributeNames = ['BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'];
for (var i = 0; i < cssAttributeNames.length; i++) {
var attributeName = cssAttributeNames[i];
if (window.document.body.style[attributeName] !== undefined) {
this._useCss = true;
break;
}
}
But this doesn't seem to work for IE9, which does support border-radius. Am I missing something?
回答1:
Got it - the detection array needs 'borderRadius' added - it's case-sensitive.
回答2:
Modernizr is a Javascript library used to detect HTML5 features (including border-radius
), so if you're looking for a ready made solution, check that out.
来源:https://stackoverflow.com/questions/5277288/how-to-use-feature-detection-to-know-if-browser-supports-border-radius-includi