Quiz software, teaching tools, exam revision aids, learning games, courseware authoring
Java Menus
Java menu homeJava downloadBuy a java menuJava menu help centreContact us
Java menus » Java menu knowledge base

 SEARCH

 MENUS BY TYPE

 Drop-down menus

 Animated buttons

 Tree menus

 Sliding menus

 Tab menus

 Image maps

 MENUS BY NAME

 X-Bar menus

 iPOP menus

 iSlide menus

 iTree menus

 iTab menus

 iMMap menus

 Sensomap menus

 Magic menus

 MENU DESIGN

 Menu design

 Drop-down menus

 Web buttons

 Tree menus

 Sliding menus

 Menu tabs

 Image maps

 SITE LINKS

 Home

 Java downloads

 Prices / Buying

 Support

 Company

 Contact

 New menus

 Free menus

 PARTNER SITES

 Alien Menus

 Happy Menus
Java menu knowledge base
Browser and OS detection
Return to knowledge base directory

 
Detecting browsers and operating systems
 
Just in case you want to write your own javascript detectors and page redirection routines, we offer some free code below for doing it.
 
1. How to detect the browser version
 
The browser manufacturer (e.g. Microsoft, Netscape) is given by the javascript command "navigator.appName". The version is given by "navigator.appVersion". The version is a long list of information starting with the version number (e.g. 3.04, 4.01), and continuing with information about the platform, language and other details. The following code shows you this information.
<script>
browser = navigator.appName;
version = navigator.appVersion;
alert(browser + " " + version);
<script>
Click here to run this script.
 
The following code checks whether you are running a version 4 browser or higher (Microsoft or Netscape), and loads a page depending on the result - "oldpage.htm" is for the older browsers; "newpage.htm" is for the newer ones.
<script>
version = navigator.appVersion;
if (version.substring(0,1)<4) location = "oldpage.htm";
else location = "newpage.htm";
<script>
2. How to detect the operating system
 
If you want to detect OS and platform, you must be slightly more careful. The javascript "appVersion" string varies in the way it names operating systems and where it places the name in the string. For example, Microsoft Windows might be called "WinPC", "Win95", "Win98", "WinNT", "Windows NT", "Windows 95", and so on, possibly with variation between upper and lower case. But one thing is fairly certain: anything running Windows has the string "win" somwhere in it (even if there are more letters as well), and a Mac browser always has the string "mac" (even if the full string is "Macintosh").
<script>
version = navigator.appVersion;
if (version.toLowerCase().indexOf("win")!=-1) location = "winpage.htm";
else if (version.toLowerCase().indexOf("mac")!=-1) location = "macpage.htm";
else location = "otherpage.htm";
<script>
The above code branches between three pages: "winpage.htm" is for Windows users; "macpage.htm" is for Mac users; "otherpage.htm" is for anybody else. Click here to try the script.
 

 
java menu