How to detect Mobile device using JavaScript
Here is how to detect if user has opened site in mobile device or desktop. For this we're using JavaScript code which will be executed at client-side.
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {