Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

browsers 1

Status
Not open for further replies.

tnbrwneyez

Programmer
Oct 2, 2004
19
US
I need to take the following script and modify it to assign a separate specific code to the browser variable for 3.x version of IE or Netscape.


<html>
<head>
<title>Browser Detection</title>
<script language="JavaScript" type="text/javascript">
//check for 5.0 or later browsers
if (parseInt(navigator.appVersion) >= 5
|| navigator.appVersion.indexOf("MSIE 5") != -1) {
browser="DOM";
} else if (navigator.userAgent.indexOf("Mozilla/4") != -1)
{
if (navigator.appName.indexOf("Netscape") != -1)
browser="NS4";
if (navigator.appVersion.indexOf("MSIE 4") != -1)
browser="IE";
} else browser="Other";
</script>
</head>
<body>
<h1>Browser Detection Example</h1>
<script language="JavaScript" type="text/javascript">
document.write("browser detected: " + browser + "<br>");
</script>
</body>
</html>

Please help!

Thanks
 
Code:
if ( parseFloat(navigator.appVersion) >= 4)
{
  // 4 and above
} else {
  // 3 and below
}

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
sorry, but where do I put that script in the code?

Thanks!
 
What are you planning to do with it? It depends on the application.

All you are doing in the given code is printing out the browser.

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
All I know is that I need to assign a separate specific code to the browser variable for 3.x version of IE or Netscape. I think that I need to jsut add this to include the versions 3.x.

Thanks
 
Code:
<html>
<head>
<title>Browser Detection</title>
<script language="JavaScript" type="text/javascript">

if (parseFloat(navigarot.appVersion) >= 4)
{
  //check for 5.0 or later browsers
  if (parseInt(navigator.appVersion) >= 5
|| navigator.appVersion.indexOf("MSIE 5") != -1)  
  {
    browser="DOM";
  } else if (navigator.userAgent.indexOf("Mozilla/4") != -1) {
     if (navigator.appName.indexOf("Netscape") != -1) browser="NS4";
     if (navigator.appVersion.indexOf("MSIE 4") != -1) 
browser="IE";
   } else browser="Other";
 }
} else {
  browser = "Browser version is less than 4! Time to upgrade!"; // Edit this
}
</script>
</head>
<body>
<h1>Browser Detection Example</h1>
<script language="JavaScript" type="text/javascript">
document.write("browser detected: " + browser + "<br>");
</script>
</body>
</html>

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top