Do not think "discover Opera."
Think of "detecting browsers that do not support the x function." For example, this JavaScript statement allows you to detect browsers that support moz-border-radius:
typeof (getComputedStyle(document.body, '').MozBorderRadius)=='string'
and this is the equivalent for WebKit-based browsers (Safari, Chrome):
typeof (getComputedStyle(document.body, '').WebKitBorderRadius)=='string'
Combining this, we can come up with something like
function detectBorderRadiusSupport(){ var styleObj; if( window.getComputedStyle ){ styleObj=window.getComputedStyle(document.body, ''); }else{ styleObj=document.body.currentStyle; } return typeof styleObj.BorderRadius != 'undefined' || typeof styleObj.MozBorderRadius != 'undefined' || typeof styleObj.WebKitBorderRadius != 'undefined'; } // the below must be inside code that runs when document.body exists, for example from onload/document.ready/DOMContentLoaded event or inline in body if(!detectBorderRadiusSupport())document.body.className+=' fakeBorderRadius';
CSS
body.fakeBorderRadius .roundMyCorners{ }
Caution: untested: -p
hallvors Aug 26 '09 at 14:29 2009-08-26 14:29
source share