Reputation: 33
Is there any way to hide the site only for android devices?
Maybe there is an option to redirect android users to a separate page?
Thanks.
Upvotes: 0
Views: 88
Reputation: 682
You can firstly check the user agent to distinguish Android devices.
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
If is an Android device do the redirect
if (/android/i.test(userAgent)) {
window.location.href = "http://www.google.com";
}
Wrap all the code in the page load function
window.onload = function() {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
window.location.href = "http://www.google.com";
}
};
Upvotes: 4