Wireless Access

last person joined: 22 hours ago 

Access network design for branch, remote, outdoor, and campus locations with HPE Aruba Networking access points and mobility controllers.
Expand all | Collapse all

repost of the useful code snippet for client autodetection through web browser

This thread has been viewed 1 times
  • 1.  repost of the useful code snippet for client autodetection through web browser

    Posted Dec 30, 2011 01:38 AM

    Hi all,

     

    it seems that the import of all the airheads data into the new forum nerfed the code snippet that I posted to help detect client versions for the VIA welcome.html page (including detecting Windows 64 bit OS running a 32 bit browser). This assumes that you have already uploaded VIA clients into your controller for Win32, Win64 and MacOS.

     

     

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>Welcome VIA user</title>
    <script>
    <!--
    function init() {
    var clientVersion = navigator.platform;
    var osVersion = null;
    if (navigator.userAgent.indexOf("Windows NT 5.1")!=-1) {
    osVersion = "Windows XP";
    } else if (navigator.userAgent.indexOf("Windows NT 6.0")!=-1) {
    osVersion = "Windows Vista";
    } else if (navigator.userAgent.indexOf("Windows NT 6.1")!=-1) {
    osVersion = "Windows 7";
    } else if (navigator.userAgent.indexOf("Macintosh")!=-1) {
    osVersion = "Mac OS";
    }
    var msg = "We have made our best guess at detecting your operating " +
    "system and have determined it to be: " + osVersion;
    var dw_msg = "If this is correct, download your VIA client here:";
    var admin_msg = null;
    var os = null;
    if (clientVersion == "Win64" || navigator.userAgent.indexOf('WOW64')) {
    msg += " 64 bit";
    os = "win64";
    } else if (clientVersion == "Win32") {
    msg += " 32 bit";
    os = "win32";
    } else if (clientVersion == "MacIntel") {
    os = "osx";
    } else {
    msg = "Currently we do are not supproting: " + clientVersion;
    admin_msg = "Please check with your system administrator to see if a version of VIA is available for your operating system.";
    dw_msg = null;
    }
    document.getElementById('msg').innerHTML = msg;
    if (dw_msg) document.getElementById('dw_msg').innerHTML = dw_msg;
    if (admin_msg)
    document.getElementById('admin_msg').innerHTML = admin_msg;
    else
    document.getElementById('admin_msg').style.display = 'none';
    var download = '';
    var other    = '';
    if (os)
    download = '<a href="/via/download?os=' + os + '">VIA Installer ('+ clientVersion + ')</a>'
    document.getElementById('download').innerHTML = download;
    document.getElementById('other').innerHTML = other;
    }
    </script>
    </head>
    <body onload="init()">
    Welcome VIA user <b><% user %></b>@<% ip %>/<% role %>
    <p id="msg" style="color:#B30004;font-size:18px;font-weight:bold;"></p>
    <p id="admin_msg" style="color:#0011AA;font-size:15px;font-weight:bold;"></p>
    <div style="margin-bottom:20px;">
    <span id="dw_msg" style="font-size:15px;font-weight:bold;margin-right:10px;"></span>
    <div id="download"></div>
    </div>
    <input type="button" name="Logout" value="Logout"  onclick="javascript&colon;location.href='<% logout %>'"
    </body>
    </html>

     



  • 2.  RE: repost of the useful code snippet for client autodetection through web browser

    EMPLOYEE
    Posted Jan 02, 2012 08:07 PM
    Ian,

    Thank you. This will be useful for users that cannot update to 6.1.2.4 immediately.


  • 3.  RE: repost of the useful code snippet for client autodetection through web browser

    Posted Jan 03, 2012 03:55 AM

    I've tested this on a couple of OS and it's not completely working i think:

    - MacOSX is fine

    - Windows XP 32 bit with IE/FF detects as Windows XP 64 bit

    - Windows 7 64 bit with IE/FF detects as 64-bit but the download text shows:

    VIA installer (32bit)

     

    I'm running 6.1.2.5 code - auto detection is still a problem with 64 bit hosts being detected as 32 bit, that's why I'm looking into a solution.



  • 4.  RE: repost of the useful code snippet for client autodetection through web browser

    EMPLOYEE
    Posted Jan 03, 2012 03:58 AM

    Theymans,

     

    On 6.1.2.5, which 64 bit hosts did you use, and what browser?  In addition, what result did you get?

     

     



  • 5.  RE: repost of the useful code snippet for client autodetection through web browser

    Posted Jan 03, 2012 04:03 AM

    I've tested with Windows 7 SP1 64 bit IE 9, result:

     

    We have made our best guess at detecting your operating system and have determined it to be: Windows 7 32 bit
    If this is correct, download your VIA client here:
    VIA Installer (Win32)

     

    However when I test it with the IE 9 64 bit version, it's OK and gives me Windows 7 64 bit.

     

    But in my opinion it should detect the OS architecture, not the browser which could be 32 or 64 bit on a 64 bit OS.



  • 6.  RE: repost of the useful code snippet for client autodetection through web browser

    EMPLOYEE
    Posted Jan 07, 2012 05:40 PM

    theymans,

     

    It is difficult to reliably detect a 64-bit OS in a 32-bit browser, is the issue.

     

     

    http://stackoverflow.com/questions/1741933/detect-64-bit-or-32-bit-windows-from-user-agent-or-javascript

     



  • 7.  RE: repost of the useful code snippet for client autodetection through web browser

    EMPLOYEE
    Posted Mar 14, 2012 12:54 AM

    theymans, there is a small typo in the script, the following:

     

    if (clientVersion == "Win64" || navigator.userAgent.indexOf('WOW64')) {
    msg += " 64 bit";
    os = "win64";

     

    should be changed as follows, i think this may be responsible for some of the false hits on win64 being reported here

     

    if (clientVersion == "Win64" || navigator.userAgent.indexOf('WOW64') != -1) {
    msg += " 64 bit";
    os = "win64

     

     

     



  • 8.  RE: repost of the useful code snippet for client autodetection through web browser

    Posted Mar 15, 2012 09:22 PM

    thanks for the correction there Jeff... the original snippet that we created was missing that too!



  • 9.  RE: repost of the useful code snippet for client autodetection through web browser

    Posted Feb 18, 2013 12:32 PM

    is this snippet to be loaded onto the controller that supports VIA? Does the snippet need the modification for the 64 bit? I have users running 64 bit machines with 32 bit browsers and they can't download 64 bit version. Just looking for clarification as to how to make this work.

     

    Thanks



  • 10.  RE: repost of the useful code snippet for client autodetection through web browser

    Posted Feb 19, 2013 05:04 PM

    the code segment (including spelling errors!) can be loaded into the welcome.html page on the controller that is presenting the VIA download (generally https://<IP.OF.MOBILITY.CONTROLLER>/via/welcome.html to provide an autodetection capability to present clients with the correct version of VIA to download. This assumes that you already have loaded in the VIA clients into the controller as well, otherwise clients won't get a valid link.

     

    I've just checked one of my controllers running an ArubaOS 6.1.3 variant and this feature is in there already, so you shouldn't have to add it in (and it avoids a couple of my spelling mistakes!). I can't remember exactly when this was introduced into the firmware so you may already have it; just download the page from the controller and have a look.