CSS filters are an Internet Explorer-specific feature. If you apply CSS filters from JavaScript, Opera and other non-IE browsers will throw an error because CSS filters are not supported.
Scripts normally try to work around this with browser detection, or semi-browser-detection where the script tests if a specific object exists and guesses based on that what browser the visitor is running.
Browser sniffers can be quite complex with the huge number of browsers and versions, and it needs constant maintenance. It is simpler and more logical to test for the object your script requires, known as JavaScript object detection.
For example:
old code:
if(ie){
someHTMLElement.style.filter.alpha.opacity = 100;
}
New code:
if(typeof someHTMLElement.style.filter !='undefined' ){
someHTMLElement.style.filter.alpha.opacity = 100;
}
The new code has several advantages: because it tests for capability rather than browser name and version, a clunky and error-prone browser sniffer is no longer required. Better still: this requires no maintenance! Even if, say, CSS filters became a W3 recommendation and Opera implements it you will not have to change your script.
Need help? Hit F1 anytime while using Opera to access our online help files, or go here.