JavaScript detect mobile device browser | HTML Example code

HTML webpage can detect detect mobile device using JavaScript. Use the JavaScript with regular expression test to detect if browser is a mobile device or not.

Example of JavaScript detect mobile device browser

Here’s a code that uses an insanely long and comprehensive regex which returns a true or false value depending on whether or not the user is browsing with a mobile.

Output:

JavaScript detect mobile device browser

Do comment if you have another better way or doubts or suggestion on this topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.