Quantcast
Viewing all articles
Browse latest Browse all 13

Answer by Sandro Rosa for Detect 64-bit or 32-bit Windows from User Agent or Javascript?

I resumed the results of the nice search above into these JS functions. Hope they can help everybody here to catch up a quick response to their needs (and, as well, to mine too !)

function get_bits_system_architecture()
{
    var _to_check = [] ;
    if ( window.navigator.cpuClass ) _to_check.push( ( window.navigator.cpuClass + "" ).toLowerCase() ) ;
    if ( window.navigator.platform ) _to_check.push( ( window.navigator.platform + "" ).toLowerCase() ) ;
    if ( navigator.userAgent ) _to_check.push( ( navigator.userAgent + "" ).toLowerCase() ) ;

    var _64bits_signatures = [ "x86_64", "x86-64", "Win64", "x64;", "amd64", "AMD64", "WOW64", "x64_64", "ia64", "sparc64", "ppc64", "IRIX64" ] ;
    var _bits = 32, _i, _c ;
    outer_loop:
    for( var _c = 0 ; _c < _to_check.length ; _c++ )
    {
        for( _i = 0 ; _i < _64bits_signatures.length ; _i++ )
        {
            if ( _to_check[_c].indexOf( _64bits_signatures[_i].toLowerCase() ) != -1 )
            {
               _bits = 64 ;
               break outer_loop;
            }
        }
    }
    return _bits ; 
}


function is_32bits_architecture() { return get_bits_system_architecture() == 32 ? 1 : 0 ; }
function is_64bits_architecture() { return get_bits_system_architecture() == 64 ? 1 : 0 ; }

Test it:

document.write( "Which is my current bits system architecture ? " + get_bits_system_architecture() + "<br>" );

document.write( "Is it 32 bits ? " + ( is_32bits_architecture() ? "YES" : "NO" ) + "<br>" );

document.write( "Is it 64 bits ? " + ( is_64bits_architecture() ? "YES" : "NO" ) );

Thanks to everyone!


Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>