JS前端開發(fā)判斷是否是手機端并跳轉(zhuǎn)操作(小結(jié))
常用跳轉(zhuǎn)代碼
<script type="text/javascript"> // borwserRedirect (function browserRedirect(){ var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad'; var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os'; var bIsMidp = sUserAgent.match(/midp/i) == 'midp'; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4'; var bIsUc = sUserAgent.match(/ucweb/i) == 'web'; var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce'; var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile'; var bIsAndroid = sUserAgent.match(/android/i) == 'android'; if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM || bIsAndroid ){ window.location.href = '跳轉(zhuǎn)的移動端網(wǎng)址'; } })(); </script> <script type="text/javascript"> <!-- //平臺、設(shè)備和操作系統(tǒng) var system = { win: false, mac: false, xll: false, ipad:false }; //檢測平臺 var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); system.ipad = (navigator.userAgent.match(/iPad/i) != null)?true:false; //跳轉(zhuǎn)語句,如果是手機訪問就自動跳轉(zhuǎn)到wap.baidu.com頁面 if (system.win || system.mac || system.xll||system.ipad) { } else { window.location.; } --> </script>
騰訊跳轉(zhuǎn)
<script type="text/javascript"> if(window.location.toString().indexOf('pref=padindex') != -1){ }else{ if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){ if(window.location.href.indexOf("?mobile")<0){ try{ if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){ window.location.; }else if(/iPad/i.test(navigator.userAgent)){ //window.location. }else{ window.location. } }catch(e){} } } } </script> <script type="text/javascript"> <!-- //平臺、設(shè)備和操作系統(tǒng) var system = { win: false, mac: false, xll: false, ipad:false }; //檢測平臺 var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); system.ipad = (navigator.userAgent.match(/iPad/i) != null)?true:false; //跳轉(zhuǎn)語句,如果是手機訪問就自動跳轉(zhuǎn)到wap.baidu.com頁面 if (system.win || system.mac || system.xll||system.ipad) { } else { window.location.; } --> </script>
JS 判斷瀏覽器客戶端類型(ipad,iphone,android)
<script type="text/javascript"> var bForcepc = fGetQuery("dv") == "pc"; function fBrowserRedirect(){ var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if(bIsIpad){ var sUrl = location.href; if(!bForcepc){ window.location.; } } if(bIsIphoneOs || bIsAndroid){ var sUrl = location.href; if(!bForcepc){ window.location.; } } if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){ var sUrl = location.href; if(!bForcepc){ window.location.; } } } function fGetQuery(name){//獲取參數(shù)值 var sUrl = window.location.search.substr(1); var r = sUrl.match(new RegExp("(^|&)" + name + "=([^&]*)(&|$)")); return (r == null ? null : (r[2])); } function fShowVerBlock(){ if(bForcepc){ document.getElementByIdx_x("dv_block").style.display = "block"; } else{ document.getElementByIdx_x("ad_block").style.display = "block"; } } fBrowserRedirect(); </script>
以上所述是小編給大家介紹的JS前端開發(fā)判斷是否是手機端并跳轉(zhuǎn)操作,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的,在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- JS如何實現(xiàn)網(wǎng)站中PC端和手機端自動識別并跳轉(zhuǎn)對應(yīng)的代碼
- JS跳轉(zhuǎn)手機站url的若干注意事項
- js根據(jù)手機客戶端瀏覽器類型,判斷跳轉(zhuǎn)官網(wǎng)/手機網(wǎng)站多個實例代碼
- 基于JavaScript代碼實現(xiàn)pc與手機之間的跳轉(zhuǎn)
- js判斷手機訪問或者PC的幾個例子(常用于手機跳轉(zhuǎn))
- 兩款JS腳本判斷手機瀏覽器類型跳轉(zhuǎn)WAP手機網(wǎng)站
- JS腳本根據(jù)手機瀏覽器類型跳轉(zhuǎn)WAP手機網(wǎng)站(兩種方式)
- JSP中實現(xiàn)判斷客戶端手機類型并跳轉(zhuǎn)到app下載頁面
- 百度判斷手機終端并自動跳轉(zhuǎn)js代碼及使用實例
- 手機平板等移動端適配跳轉(zhuǎn)URL的js代碼
- JS自動跳轉(zhuǎn)手機移動網(wǎng)頁的實現(xiàn)方法
相關(guān)文章
JavaScript實現(xiàn)為指定對象添加多個事件處理程序的方法
這篇文章主要介紹了JavaScript實現(xiàn)為指定對象添加多個事件處理程序的方法,可實現(xiàn)讓指定對象處理多個事件的功能,具有一定參考借鑒價值,需要的朋友可以參考下2015-04-04JS循環(huán)發(fā)送請求時控制請求并發(fā)數(shù)實例
這篇文章主要介紹了JS循環(huán)發(fā)送請求時控制請求并發(fā)數(shù)實例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12javascript實現(xiàn)多欄閉合展開式廣告位菜單效果實例
這篇文章主要介紹了javascript實現(xiàn)多欄閉合展開式廣告位菜單效果,可實現(xiàn)類似手風(fēng)琴切換展示效果的功能,具有一定參考借鑒價值,需要的朋友可以參考下2015-08-08javascript textContent與innerText的異同分析
因為發(fā)現(xiàn)網(wǎng)絡(luò)上很少有這方面的內(nèi)容,因此就把自己私有blog上的這篇文章搬出來到Boluor的公開blog,方便其它人查閱。2010-10-10layui: layer.open加載窗體時出現(xiàn)遮罩層的解決方法
今天小編就為大家分享一篇layui: layer.open加載窗體時出現(xiàn)遮罩層的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09input標(biāo)簽內(nèi)容改變的觸發(fā)事件介紹
onchange事件在內(nèi)容改變(兩次內(nèi)容有可能相等)且失去焦點時觸發(fā);onpropertychange事件是實時觸發(fā),每增加或刪除一個字符就會觸發(fā)2014-06-06