CSS and DHTML
DHTMLTesting for features
One possibility is to use Javascript to query the browser to see if a particular feature or object is available
This method is not testing for the presence of the browser's DOM directly
It can be used to test for any feature
It requires an additional page that appears before the page using the features for which you are testing
The markup looks like this:
<script language="javascript">
if (document.images) {
document.write('Image-swapping is available here!');
}
else {
document.write('No image-swapping allowed here');
}
</script>
This script uses a conditional (if --> else) statement to test the browser
The document.write function instructs the browser to take an action depending on the outcome of the conditional test
To test for the presence of a different feature, provide the DOM filepath for that feature
Here's an example (close the window to return to this page)
You are here: http://memex.lib.indiana.edu/hrosenba/www/Workshops/CSS/Demo/cssdhtm2.html
Last updated 3.15.06 - H. Rosenbaum