Style Sheet based upon Browser

[Total: 0    Average: 0/5]

This example shows how to determine which web browser the web serfer is using, and then use the style sheet intended for that user’s web browser.

Head Code:

<script>
var isIE = document.all?true:false;
var isNS = document.all?true:false;
if (isIE) document.write("<style type=text/css>.test {color:red}</style>");
else if (isNS) document.write("<style type=text/css>.test {color:green}</style>");
else document.write("<style type=text/css>.test {color:blue}</style>");
</script>
<noscript>
<style type=text/css>
.test {color:#FFFF00}
</style>
</noscript>

Body Code:

<div class="test">THIS IS TEST TEXT</div>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *