隨著科技的不斷發(fā)展,現(xiàn)在很多人都使用智能手機(jī)上網(wǎng),但是當(dāng)我們下載網(wǎng)站會(huì)通過判斷不同的系統(tǒng)手機(jī)訪問不同的網(wǎng)頁,下面小編帶大家一起來了解一下SPA的種類有哪些呢?感興趣的朋友一起來看看。
/// <summary>/// 判斷手機(jī)用戶UserAgent/// </summary>/// <returns></returns>private bool IsMobile(){ HttpContext context = HttpContext.Current; if (context != null) { HttpRequest request = context.Request; if (request.Browser.IsMobileDevice) return true; string MobileUserAgent=System.Configuration.ConfigurationManager.AppSettings["MobileUserAgent"]; Regex MOBILE_REGEX = new Regex(MobileUserAgent); if (string.IsNullOrEmpty(request.UserAgent) || MOBILE_REGEX.IsMatch(request.UserAgent.ToLower())) return true; } return false;}以下為web.config配置里邊的
?
<script>var system ={ win : false, mac : false, xll : 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);//跳轉(zhuǎn)語句if(system.win||system.mac||system.xll){ alert(system.mac)}else{ window.location.href="手機(jī)訪問地址";}</script>上文就是錯(cuò)新技術(shù)頻道小編介紹的asp.net及javascript判斷是否手機(jī)訪問的方法,看完后你明白了嗎?感興趣的朋友還可以多了解js.VeVb.com網(wǎng)站吧!新聞熱點(diǎn)
疑難解答
圖片精選