Enable buttons for windows, and Windows 32 and 64 Bit

Asked

Viewed 23 times

0

Hello, I need your help because I have a problem related to this code, in it I need to distinguish which Windows the person uses, and if it is 32 or 64. But I do not know what is wrong, I am new in this area, could 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>

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) {

Another thing that might help you, you already have the information in the object itself. See if this no longer solves for you:

alert(navigator.oscpu);
  • Nosssaaa, very much obliged aaa... You helped so much, Thank you really, Valleuuu

0

Missing a couple of parentheses on your if I am Thus remaining:

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

However from what I saw you will only have Osname 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.

  • Thank you truly, Valleuuu

Browser other questions tagged

You are not signed in. Login or sign up in order to post.