Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    May 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How would I run this?

    If I want to put this on a script for people to check, how would I do this?

    Here's the code:
    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.
       }
    }                                                                        
    // -->
    Need tech support? Are you a techie?
    Then check out TechieHQ - Your Tech Support HeadQuarters

  • #2
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You mean checking if a person is running Internet Explorer in SP2 and then do something based on if he is or not?
    <JPM />

  • #3
    New Coder
    Join Date
    May 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Need tech support? Are you a techie?
    Then check out TechieHQ - Your Tech Support HeadQuarters

  • #4
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)
       {
       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>
    <JPM />

  • #5
    New Coder
    Join Date
    May 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That doesn't do anything at all...
    Need tech support? Are you a techie?
    Then check out TechieHQ - Your Tech Support HeadQuarters

  • #6
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what exactly did you put: show the source, please.

  • #7
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    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)
       {
    
    
       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

  • #8
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And one more to make it actually work:

    Code:
    <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>

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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:
    Code:
    var s='';
    for (i in navigator)
       s+=i+' = '+navigator[i]+'\n';
    alert(s);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •