...

View Full Version : How would I run this?



ogden2k
08-11-2004, 03:13 PM
If I want to put this on a script for people to check, how would I do this?

Here's the code:
<!-- Do I have Service Pack 2 install for Windows XP?
var g_fIsSP2 = false;
function browserVersion()
{
g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
if (g_fIsSP2)
{
//This browser is Internet Explorer in SP2.
}
else
{
//This browser is not Internet Explorer in SP2.
}
}
// -->

JPM
08-11-2004, 03:23 PM
You mean checking if a person is running Internet Explorer in SP2 and then do something based on if he is or not?

ogden2k
08-11-2004, 03:32 PM
I'm trying to take this code and put it on a page so someone can load the page, and it will tell them if they have SP2. It's sort of useless, but I want to know how to do it.

It's sort of like checking your own user agents.

JPM
08-11-2004, 03:42 PM
<!-- Do I have Service Pack 2 install for Windows XP?
var g_fIsSP2 = false;
function browserVersion()
{
g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
if (g_fIsSP2)
{
document.getElementById('myDiv').innerHTML = "You are using IE in SP2"
}
else
{
document.getElementById('myDiv').innerHTML = "You are not using IE in SP2"
}
}
// -->

.......
.........
............

<div id="myDiv"></div>

ogden2k
08-11-2004, 06:22 PM
That doesn't do anything at all...

jbot
08-11-2004, 06:29 PM
what exactly did you put: show the source, please.

dumpfi
08-11-2004, 06:30 PM
<!-- Do I have Service Pack 2 install for Windows XP?
var g_fIsSP2 = false;
function browserVersion()
{
g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
if (g_fIsSP2)
{


document.getElementById('myDiv').innerHTML = "You are using IE in SP2"
}
else
{
document.getElementById('myDiv').innerHTML = "You are not using IE in SP2"
}
}
window.onload = browserVersion;
// -->

.......
.........
............

<div id="myDiv"></div>dumpfi

AaronW
08-11-2004, 07:17 PM
And one more to make it actually work:


<script type="text/javascript">
<!-- Do I have Service Pack 2 install for Windows XP?
var g_fIsSP2 = false;
function browserVersion()
{
g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
if (g_fIsSP2)
{


document.getElementById('myDiv').innerHTML = "You are using IE in SP2"
}
else
{
document.getElementById('myDiv').innerHTML = "You are not using IE in SP2"
}
}
window.onload = browserVersion;
// -->
</script>
.......
.........
............

<div id="myDiv"></div>

glenngv
08-12-2004, 05:00 AM
Do you really want the SP information of the OS and not the browser? They are different. And I think you can't detect the SP of OS in the browser. But if you really want the SP info of IE itself, you should use appMinorVersion instead. userAgent doesn't contain SP info.

Try this code to see what navigator object can detect:


var s='';
for (i in navigator)
s+=i+' = '+navigator[i]+'\n';
alert(s);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum