Demo How to Detect Mobile Device using JavaScript

Using JavaScript's window.matchMedia() and CSS media queries.

This method is more reliable than depending on the navigator.userAgent property.

Back to Tutorial