如何偵測使用者的裝置是否為行動裝置

如何偵測使用者的裝置是否為行動裝置

轉貼

function isMobileDevice() {
    const mobileDevice = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone']
    let isMobileDevice = mobileDevice.some(e => navigator.userAgent.match(e))
    return isMobileDevice
}

參考

如何偵測使用者的裝置是否為行動裝置 | Jason’s BLOG