Como obtengo el Sistema Operativo
Sé que con un formulario, un comando de JavaScript y un campo de texto oculto puedo obtener el sistema operativo del usuario. Ya lo he usado, solo que no recuerdo como era.
Yo tengo este codigo hecho por lizfranco y mejorado por Kaopectate, yo he añadido la localización de Windows XP, pero no estoy seguro de que vaya bien, si tienes XP funciona, pero puede que tambien salte con otro SO.
No tiene nada que ver con lo que habÃas usado tu de formularios y campos de texto ocultos, pero si funciona, que mas da ¿no?
<html>
<head>
<script language="JavaScript">
function checkOS(){
var sAgnt = navigator.userAgent;
var OpSys = 'other';
var bWin = (sAgnt.indexOf('Win') != -1);
if (bWin){
OpSys = "Windows NT or Windows 3.1 or ME";
if (sAgnt.indexOf('98') != -1) OpSys = "Windows 98";
if (sAgnt.indexOf('95') != -1) OpSys = "Windows 95";
if (sAgnt.indexOf('NT 5.0') != -1) OpSys = "Windows 2000";
//Lo he añadido yo, se que salta si es XP, pero no se si tambien salta con algun otro SO.
if (sAgnt.indexOf('NT 5.1') != -1) OpSys = "Windows XP";
} else {
if (sAgnt.indexOf('IRIX') != -1) OpSys = "Irix";
if (sAgnt.indexOf('Mac') != -1) OpSys = "Macintosh";
if (navigator.appName=="WebTV Internet Terminal") OpSys="WebTV";
}
return OpSys;
}
function alertOS(){
alert(checkOS());
}
</script>
</head>
<body>
<form name="frm">
<input type="button" name="os" value="Probar función" onclick="alertOS()">
</form>
</body>
</html>
Espero que te sirva
rsalvadores
No tiene nada que ver con lo que habÃas usado tu de formularios y campos de texto ocultos, pero si funciona, que mas da ¿no?
<html>
<head>
<script language="JavaScript">
function checkOS(){
var sAgnt = navigator.userAgent;
var OpSys = 'other';
var bWin = (sAgnt.indexOf('Win') != -1);
if (bWin){
OpSys = "Windows NT or Windows 3.1 or ME";
if (sAgnt.indexOf('98') != -1) OpSys = "Windows 98";
if (sAgnt.indexOf('95') != -1) OpSys = "Windows 95";
if (sAgnt.indexOf('NT 5.0') != -1) OpSys = "Windows 2000";
//Lo he añadido yo, se que salta si es XP, pero no se si tambien salta con algun otro SO.
if (sAgnt.indexOf('NT 5.1') != -1) OpSys = "Windows XP";
} else {
if (sAgnt.indexOf('IRIX') != -1) OpSys = "Irix";
if (sAgnt.indexOf('Mac') != -1) OpSys = "Macintosh";
if (navigator.appName=="WebTV Internet Terminal") OpSys="WebTV";
}
return OpSys;
}
function alertOS(){
alert(checkOS());
}
</script>
</head>
<body>
<form name="frm">
<input type="button" name="os" value="Probar función" onclick="alertOS()">
</form>
</body>
</html>
Espero que te sirva
rsalvadores