Is there a way to detect the device when going on a website to change the content

71 Views Asked by At

I want to do the following, when somebody visits my website on the phone it should say "please visit from desktop" and when it gets visited by desktop its normal. How can I make the website detect the device and so on?

1

There are 1 best solutions below

2
Reactor On

try to add this code in html header

<script>
  if (/Android|iPhone/i.test(navigator.userAgent)) {
    document.querySelector("body").textContent = "Please, visit from desktop!";
  }
</script>