0

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.

1 Answer 1

4

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"; } }; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.