-1

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?

starball
  • 20,030
  • 7
  • 43
  • 238

1 Answers1

-1

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>
Reactor
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 07 '23 at 13:33
  • didn't work at all – q2000 official Mar 15 '23 at 19:12