...

View Full Version : Testing for specific CSS features.



martijntje
03-18-2005, 11:26 AM
In order to make sure users get the best experience when using my website, i want to make use of the CSS3 opacity feature (or any other proprietary tag other browsers may use). Therefor i need to test if the browser supports these properties. I have come up with the following code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Test</title>
<script type="application/x-javascript">
window.onload=test_opacity;
function test_opacity()
{
alert(document.getElementById('test').style.opacity);
}
</script>
</head>
<body>
<div id="test" style="opacity: 0.5;">
test
</test>
</body>
</html>

This appears to work. For example, Opera gives me "undefined" alert.
However, i am afraid that other browsers that also don't support these features simply return the value, and ignore it for the rest.

Can someone tell me if this is a good way to test for CSS functionality?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum