Enable buttons for windows, and Windows 32 and 64 Bits

0

Hello, I need your help because I have a problem related to this code, at first I need to distinguish which Windows the person uses, and if he is 32 or 64. But I do not know what's wrong, I'm new to this area, could you help me?

Code:

 <html>
<head>
<title>Teste</title>
<script type="text/javascript">
var OSName = "";
    function sistema(){
        if((window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1)&&
(navigator.userAgent.indexOf('32')!= -1)){
         OSName = "Windows 10 --> 32bits";}
        else if(window.navigator.userAgent.indexOf("Windows NT 10.0")!= 
-1)&&(navigator.userAgent.indexOf('64')!= -1){
         OSName = "Windows 10 --> 64bits";} 

         alert(OSName);
}
</script>
</head>
<body onload="sistema()">
    <input type="submit" name="Teste" value="Teste" 
onclick="javascript:sistema();">

</body>
</html>
    
asked by anonymous 04.09.2017 / 22:18

2 answers

0

This line is wrong:

else if(window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1)&&(navigator.userAgent.indexOf('64')!= -1){

You can switch to:

else if(window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1 && navigator.userAgent.indexOf('64')!= -1) {

Something else that may help you, you already have the information in the object itself. See if that does not work for you anymore:

alert(navigator.oscpu);
    
04.09.2017 / 22:44
0

Missing pair of parenthesis on your else if Staying like this:

else if((window.navigator.userAgent.indexOf("Windows NT 10.0")!= -1) && (navigator.userAgent.indexOf('64')!= -1)){

But from what I saw you will have OSName only if it is Windows 10. If it is another version it will not return anything in this variable. There you have to see your need, if that's what you need.

    
04.09.2017 / 22:46