My webpage doesn't work for mobile devices, so I want to disable mobile access, at least for now. Is there a jQuery/javascript script to disable access to a website for smartphones and mobile devices? Could it be redirected to a small 404 page (or similar) that I will setup saying that you have to visit the website on a computer? In addition, do you have any good references on designing a site for mobile access?
4 Answers
Detect Mobile Browsers provides various open source mobile phone detection scripts (including JavaScript and jQuery) which you may find useful.
To use it:
"Download a mobile browser redirect script and change http://detectmobilebrowser.com/mobile
to your mobile site's URL."

- 3,457
- 1
- 23
- 35
-
Wow nice! Good stuff... Just what I was looking for, although I appears to add adverts... – Shad Asinger Apr 16 '12 at 16:05
-
2What is `this`? An explanation of what is on the other end of the link should be added to your answer so it can be useful in the future. – Jasper Apr 16 '12 at 16:06
-
Fair point @Jasper, I've edited a more to include a more detailed explanation. – jleft Apr 16 '12 at 16:13
-
What if you switch to Desktop mode on your browser? UA changes – csandreas1 Apr 30 '18 at 16:21
-
How to stop if it is in Desktop Site? – Anuj Todankar Dec 20 '21 at 09:22
What you probably want is a server side process that determines what device the user has and that redirect him to the correct site. We use Wurlf to do the device detection. It has API's for Java and PHP so you can query it and redirect accordingly.It also gives you a ton of device capabilities on the server side. http://wurfl.sourceforge.net/.
If you want a client side detection I suggest you use modernizr: http://modernizr.com/
What you do not want to do is block access. It's better to have something rather than nothing.

- 12,798
- 6
- 36
- 59
-
Nice... could use. Was actually looking for a basic JS than a PHP, Its just that I am not experienced in PHP for customization :) – Shad Asinger Apr 16 '12 at 16:12
Don't block the site, just put a notice in top that the site is not (yet?) optimized for smartphones, so if something is not working they should use a computer.

- 21,083
- 19
- 56
- 89
-
I was planning to sort of sum the webpage up in that 404 error page instead :) thanks for the tip – Shad Asinger Apr 16 '12 at 16:10
You can do a bit of Googling to get an idea of what you need to do, actually. But do take note that this is a lot like browser sniffing, which is generally a Bad Thing™.

- 1
- 1

- 14,627
- 5
- 48
- 66