473,466 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

nested if question

I want to publish a patch CD. The CD will contain my files and an HTML page
which will autorun, and tell the user which patch to install. (The Microsoft
MSI installer v2 is comes in two different versions for 98/me and nt4/2000,
and need to install that before my patches get installed. I need to give the
users the correct MSI, so I need to know what their OS is. Most of our users
are not computer people, and have trouble clicking the mouse at the right
time, so they are not likely to be able to determine their OS. I used the
code below to determine if the user is on XP, and it seems to work. The
first line prints "4.0 (compatible; MSIE 6.0; Windows NT 5.1), and I just
test to look for the OS string. One would think there is a better way but I
have zero skill with Javascript.

(this works by itself, but not with other tests for NT 5.0, etc)
if (navigator.userAgent.indexOf('Windows NT 5.1') >= 0){
document.write("<br>")
document.write("<br>")
document.write("<br>")
document.write ("Windows XP detected");
}
else {
document.write ("XP Pro not detected");
}
I have to rely on javascript because this html page is being loaded from a
CD, not a website. I know how to interpret the numbers (5.0, 5.1, etc) to
find out what the OS is, but when I had "if" statements for each OS version,
they ALL printed "xxxxxxxx detected", so I guess a series of "if" statements
will not work. How could I do a switch or case statement to look at
"navigator.userAgent" output and write the link out for the appropriate MSI?
Is there some way I can parse only the OS version from the string, so I just
get the "Windows NT 5.1" or whatever part of the string? In other words,
everything after the last semicolon (I'll just live with the closing
bracket).

Thanks to everyone,
-Jeff Maestas

Jul 23 '05 #1
2 1734
Jeff Maestas wrote:
I have to rely on javascript because this html page is being loaded from a
CD, not a website. I know how to interpret the numbers (5.0, 5.1, etc) to
find out what the OS is, but when I had "if" statements for each OS version,
they ALL printed "xxxxxxxx detected", so I guess a series of "if" statements
will not work. How could I do a switch or case statement to look at
"navigator.userAgent" output and write the link out for the appropriate MSI?
Is there some way I can parse only the OS version from the string, so I just
get the "Windows NT 5.1" or whatever part of the string? In other words,
everything after the last semicolon (I'll just live with the closing
bracket).


"everything after the last semicolon" won't get you what you need. This
is what IE tells me on Windows ME:

appVersion = 4.0
(compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)
userAgent = Mozilla/4.0
(compatible; MSIE 6.0; Windows 98; Win 9x 4.90; .NET CLR 1.1.4322)

As you can see, everything after the last semicolon is useless for OS
determination.

But if your users can't determine there own OS, how are they going to
manage to make it through an installation process? Not being obtuse, but
knowing the OS is pretty simple. Start>Settings>Control Panel, System
Icon and most Windows will give it to your there in plain text.

But once you figure out the substring parts that you need, look into the
switch/case to do what you are wanting, instead of nested ifs.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
In article <Up********************@giganews.com>, je***@chepnt.net
enlightened us with...
I want to publish a patch CD. The CD will contain my files and an HTML page
which will autorun, and tell the user which patch to install. (The Microsoft
MSI installer v2 is comes in two different versions for 98/me and nt4/2000,
and need to install that before my patches get installed. I need to give the
users the correct MSI, so I need to know what their OS is.


Then use an HTA for windows / IE users and get the value out of the
registry.

http://content.techweb.com/winmag/fixes/2000/0901.htm

See the section marked "registry antics".

--
--
~kaeli~
All I ask is the chance to prove that money cannot make me
happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote:...
0
by: John Wilson | last post by:
Hello, I have the following code which populates as table data from a SQL Server 2000 stored proc (RSByDemoID2). Below that is the view and stored procedure which takes @DemoID as input to match...
3
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
6
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
4
by: Steve Klett | last post by:
(I posted this in ADO group, but I think this group will be better) Hi- I need to develop an FAQ section for our website. We would like to break up the FAQ by products, then categories with...
2
by: brad | last post by:
Group, I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which contains nested server user controls in order to create a tree-like hierarchy. The tree is a sort of question and...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
3
by: Cousson, Benoit | last post by:
I don't think so; my original email was mainly a question. I do agree that they are other ways to do what I'm trying to achieve; there are always several ways to solve an issue. Few days ago, I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.