文章插圖

文章插圖
手機訪問pc網站時使用js自動跳轉到移動網站域名對應的頁面鏈接javascript代碼 。這是比較典型的跳轉需求,當用戶使用手機打開pc網站鏈接時,希望能跳轉到移動網站對應的頁面,適用于網站使用兩個域名區分pc,移動端的情況 。比如www.域名.com是電腦站,m.域名.com是移動站這樣兩個域名,并且目錄結構url是一樣的,只有域名不一樣 。
此代碼當手機訪問pc站時跳轉到移動站的對應頁面,代碼放在pc站上 。最好放在<head>下面第一位,最先加載這段js,跳轉更快一點 。
【jsp實現頁面跳轉的方法 jsp中常用的頁面跳轉語句】<script type=”text/javascript”>function browserRedirect() {var hz=location.pathname;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 || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {window.location.href=http://www.mnbkw.com/jxjc/178092/”http://m.reaer.com”+hz+”#www”;} else {}}browserRedirect();
- js打開新頁面 在新頁面中進行操作 js在新窗口打開頁面
- 畢業設計選題系統可行性分析 畢業設計選題系統的設計與實現
- 阿里云郵箱注冊錯誤碼 阿里云郵箱注冊頁面
- C語言多組輸入 c++如何實現多組輸入
- 文件加密軟件開發與實現 文件加密程序設計
- html頁面設計模版 html5頁面模板大全
- Ajax異步刷新 ajax實現局部刷新頁面
- qt實現視頻播放器源碼 QT 視頻播放器
- android設計登錄頁面 安卓設計登錄界面
- android登錄頁面設計 android設計登錄頁面并實現
