OS detection with VBScript (or javascript in ie3/4)

Posted on 1998-06-09
Last Modified: 2008-02-01
Does anyone know how to use Javascript or VBScript to detect if the user is using 95, 98 or nt4?  Its gota work under IE3 and 4.

Question by:scottg
  • 2

Accepted Solution

cyberwizz earned 200 total points
ID: 1279756

The navigator.userAgent usually returns that info togther with others.
eg. Mozilla/2.0 (Win16; I)

Try this:

getOS() {
startvar = "(";
endvar = ";";
browser = navigator.userAgent;

  if(browser.charAt(i) == startvar)
browser.substring(i-1, browser.length).indexOf(endvar) + i-1;
OS = browser.substring(i+1,end);
return OS;

That should work.

Expert Comment

ID: 1279757
Oops. This line:
browser.substring(i-1, browser.length).indexOf(endvar) + i-1;

Should have read:

end = browser.substring(i-1, browser.length).indexOf(endvar) + i-1;

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now