Answer the question
In order to leave comments, you need to log in
How to check the operating system on the site and give the appropriate redirect?
Good day! I really need a script // etc, which will determine the device through which they entered the site. There are a lot of scripts, but they are all adapted to the definitions of mobile devices. It is required to skip (or redirect) all devices (mobile//linux//etc) to one site, except for devices on OS Windows. If the site is visited from Windows, then a redirect to another site should occur. How is it possible to implement this? Thank you in advance.
Answer the question
In order to leave comments, you need to log in
Thanks everyone for the replies. Solved the problem using JavaScript.
For those like me, I post my solution to the problem:
var os = 0;
if (navigator.userAgent.indexOf ('Windows') != -1) os = 1;
// alert(navigator.userAgent);
switch (os) {
case 1:
window.location.href = "http://site.ru";
break;
}
var os = 0;
if (navigator.userAgent.indexOf ('Windows') != -1) os = 1;
if (navigator.userAgent.indexOf ('Linux')!= -1) os = 2;
if (navigator.userAgent.indexOf ('Mac')!= -1) os = 3;
if (navigator.userAgent.indexOf ('FreeBSD')!= -1) os = 4;
// alert(navigator.userAgent);
switch (os) {
case 1:
window.location.href = "http://site.ru/windows";
break;
case 2:
window.location.href = "http://site.ru/linux";
break;
case 3:
window.location.href = "http://site.ru/mac_os";
break;
case 4:
window.location.href = "http://site.ru/freebsd";
break;
default:
window.location.href = "http://site.ru/other_os";
break;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question