Click to See Complete Forum and Search --> : Changing text based on browser
Could someone please post a snippet of code that showed how to change a simple text message in the body of an html document that changes based on the browswer (i.e. prints "Your browser is IE" if ie browser or "Your browser is Netscape" if netscape browser. I'm having a dickens of a time with this seemingly simple task.
Thanks,
-Tim
Khalid Ali
06-05-2003, 05:41 PM
Something along these lines will work
<script type="text/javascript">
<!--
function Process(){
var frm = document.getElementById("form1");
var len = frm.length;
}
var browser = navigator.userAgent;
function PrintBrowser(){
if(document.layers){
document.div_1.document.open();
document.div_1.document.write("<b style='color:orange'>You are using ["+browser+"]</b>");
document.div_1.document.close();
}else{
document.getElementById("div_1").innerHTML = "<b style='color:orange'>You are using ["+browser+"]</b>";
}
}
//-->
</script>
</head>
<body class="body" onload="PrintBrowser();">
<div id="div_1" style="position:relative; top:5px; padding-top:5px;">
</div>
Charles
06-05-2003, 05:41 PM
<script type="text/javascript">
<!--
document.write('<p>Your browser is ', navigator.appName, '.</p>');
// -->
</script>