我是用react腳手架跑的底層,在public中的index.html中做了當前打開的頁面是pc還是移動的判斷,pc頁面還是寫在了react項目中,可是在判斷pc端的時候并不能跳到那個頁面, 請教大神們該怎么實現?特別著急<script>function browserRedirect() {var sUserAgent = navigator.userAgent.toLowerCase();var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";var bIsMidp = sUserAgent.match(/midp/i) == "midp";var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";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.open("http://localhost:8000/src/pages/index.html");
}}browserRedirect();</script>
添加回答
舉報
0/150
提交
取消