function isMobileDevice() { return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1); };
目前支援度有:
- Safari, Chrome, IE10 and Firefox Windows 7/8 browsers
- Safari iOS
- Chrome iOS
- Opera Coast iOS
- Android Stock Browser
- Chrome for Android
- Firefox for Android
- Opera for Android
- Dolphin for Android
- IE Windows Phone 7.8 and Windows Phone 8
但已被MDN列不不推薦方法隻一,但到目前為止依然管用
來源:
https://coderwall.com/p/i817wa/one-line-function-to-detect-mobile-devices-with-javascript
@copyright MRcodingRoom
觀看更多文章請點MRcoding筆記
觀看更多文章請點MRcoding筆記