Detect Mobile device through javascript A pretty simple solution is to check for mobile device is the screen width. Almost all mobile devices have a max screen width of 480px. We can get the screen width using below statement: var screen_width = window.screen.availWidth; The only exceptions are tablet pc's like the ipad. These devices have a higher screen width than smartphones. We can use browsers user agent to determine whether this is a mobile device or not. Below is the function to determine the mobile device based on user-agent: (function(a){ if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|...