Check mobile or not by test window.orientation
if (typeof window.orientation !== 'undefined') { ... }