常用跳轉(zhuǎn)代碼
在衛(wèi)濱等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、網(wǎng)站建設(shè) 網(wǎng)站設(shè)計制作按需求定制開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站制作,成都全網(wǎng)營銷,外貿(mào)網(wǎng)站制作,衛(wèi)濱網(wǎng)站建設(shè)費用合理。
<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)操作,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的,在此也非常感謝大家對創(chuàng)新互聯(lián)網(wǎng)站的支持!
當前標題:JS前端開發(fā)判斷是否是手機端并跳轉(zhuǎn)操作(小結(jié))
新聞來源:http://m.rwnh.cn/article42/jepphc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、響應(yīng)式網(wǎng)站、網(wǎng)站策劃、軟件開發(fā)、網(wǎng)站設(shè)計公司、App設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)