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?
Asked
Active
Viewed 49 times
-1
-
Maybe take a look at [the User-Agent header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent). – starball Jan 06 '23 at 03:33
-
okay, well it doesn't look bad, do you have an example how I would need to implement that? – q2000 official Jan 06 '23 at 03:35
-
I was just popping in to see if feedback was needed on your question. I happened to be able to give a tip. Nothing more. Sorry! – starball Jan 06 '23 at 03:36
-
Does this answer your question? [Detecting a mobile browser](https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) – Stephen Ostermiller Jan 07 '23 at 13:28
-
Also: [How to detect a mobile device using jQuery](https://stackoverflow.com/questions/3514784/how-to-detect-a-mobile-device-using-jquery) – Stephen Ostermiller Jan 07 '23 at 13:29
1 Answers
-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
-