JSクライアントブラウザの種類を決定します

1  の場合(/(iPhone |アプリ| iPodの| iOS版)/ i.test(navigator.userAgent)){
 2   
3      // 警告(navigator.userAgent)。  
4      window.location.href = "iPhone.html" 5   
6 } そう であれば(/(アンドロイド)/ i.test(navigator.userAgent)){
 7   
8      // 警告(navigator.userAgent)。
9      window.location.href = "Android.html" 10   
11 } {
 12   
13      window.location.href = "pc.html" 14   
15  }。
16  
17 もし(Windowsの携帯電話)/ | iOSの| |アンドロイド/(iPhone i.test(navigator.userAgent)){
 18      window.location.href = 'mobile.html' ;
19 }
1つの VAR UA = navigator.userAgent.toLowerCase()。
2  VaRのドライブ。
3   であれば(/ iPhone |アプリ|のiPod / .TEST(UA)){
 4        = 1ドライブ5    } そう であれば(/アンドロイド/ .TEST(UA)){
 6        ドライブ= 3 7      }

 

おすすめ

転載: www.cnblogs.com/zhangzhengyang/p/11094633.html