Не думай "обнаружи оперу".
Подумайте, «обнаружить браузеры, которые не поддерживают функцию x». Например, этот оператор JavaScript позволяет обнаруживать браузеры, которые поддерживают moz-border-radius:
typeof (getComputedStyle(document.body, '').MozBorderRadius)=='string'
и это эквивалентно для браузеров на базе WebKit (Safari, Chrome):
typeof (getComputedStyle(document.body, '').WebKitBorderRadius)=='string'
Соединив это, мы можем придумать что-то вроде
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{
/* CSS for Opera and others to emulate rounded corners goes here,
typically various background-image and background-position properties */
}
Предостережение: не проверено: -p