js判斷移動端與pc端

這裏介紹使用device.js插件來判斷移動端設備前端

地址:https://github.com/matthewhud...android

示例:ios

if(device.mobile()){

    window.location.href="移動端地址";

    //alert("移動端");

} else {

    window.location.href="PC端地址";

    //alert("PC端");

}

更多設備判斷以下表格: git

Device JavaScript Method
Mobile device.mobile()
Tablet device.tablet()
Desktop device.desktop()
iOS device.ios()
iPad device.ipad()
iPhone device.iphone()
iPod device.ipod()
Android device.android()
Android Phone device.androidPhone()
Android Tablet device.androidTablet()
BlackBerry device.blackberry()
BlackBerry Phone device.blackberryPhone()
BlackBerry Tablet device.blackberryTablet()
Windows device.windows()
Windows Phone device.windowsPhone()
Windows Tablet device.windowsTablet()
Firefox OS device.fxos()
Firefox OS Phone device.fxosPhone()
Firefox OS Tablet device.fxosTablet()
MeeGo device.meego()
Television device.television()

可使用冒號來定義對齊方式:github

Device CSS Classes
iPad ios ipad tablet
iPhone ios iphone mobile
iPod ios ipod mobile
Android Phone android mobile
Android Tablet android tablet
BlackBerry Phone blackberry mobile
BlackBerry Tablet blackberry tablet
Windows Phone windows mobile
Windows Tablet windows tablet
Firefox OS Phone fxos mobile
Firefox OS Tablet fxos tablet
MeeGo meego
Desktop desktop
Television television

移動端設備方向判斷:windows

Orientation JavaScript Method
Landscape device.landscape()
Portrait device.portrait()

有公衆號啦!!!歡迎關注,不按期推薦前端技術!!!

圖片描述

相關文章
相關標籤/搜索