I am able to extract the user`s OS using JavaScript code:
if (navigator.appVersion.indexOf("Win") != -1)
But i am not able to block users of other OSs from accessing the site.
I am able to extract the user`s OS using JavaScript code:
if (navigator.appVersion.indexOf("Win") != -1)
But i am not able to block users of other OSs from accessing the site.
It is a strange requirement, and I don't know what you mean by block - you could either redirect the user, or perhaps display some kind of message explaining that the user's OS is not supported.
As you said, you are able to detect the OS and so could effectively block the user from accessing the content of your website by updating the HTML. Eg.
if (navigator.appVersion.indexOf("Win") !== -1) {
const body = document.getElementsByTagName("body")[0];
body.innerHTML = `
<div>Your operating system is not supported.</div>
`;
}