I was making this code to insert it into my website, to detect the OS from the devices, and depending which OS they have, redirect to different pages. Also, if I upload the code to my website, the href doesn't work really well, and it searches https://example.com/thehref instead of the href alone.
This is what I have been doing, to solve the problem.
<script>
var OSName = "Unknown OS";
if (navigator.userAgent.indexOf("Win") != -1) OSName = 1;
if (navigator.userAgent.indexOf("Mac") != -1) OSName = 0;
if (navigator.userAgent.indexOf("Linux") != -1) OSName = 1;
if (navigator.userAgent.indexOf("Android") != -1) OSName = 1;
if (navigator.userAgent.indexOf("like Mac") != -1) OSName = 0;
if (OSName == 1) OSName = "play.google.com";
if (OSName == 0) OSName = "apps.apple.com";
</script>
<a href="https://www.google.com" onclick="location.href=this.href+OSName;return false;"> <p>Click<br> at me!!!</p> </a>
And my idea is that every time someones click on it, it redirects them to another page, I have been searching, and it seems that onclik and target="_blank" don't work well together.
If someone knows how to solve the problem, or has an idea, feel free to comment.
Thx you all. :)