以前に添付のコードを使用してモバイル デバイスを検出したことがありますが、Windows 8 の携帯電話と Surface のいずれのバージョンでも (明らかな理由で) 機能しません。Windows 8 携帯電話と Surface の適切な userAgent がわかりません。Surface または Windows 8 携帯電話を検出できるようにするには、何を変更する必要がありますか? どんな助けでも大歓迎です!事前に感謝します。
function detect() {
var uagent = navigator.userAgent.toLowerCase();
var mobile = false;
var search_strings = [
"iphone",
"ipod",
"ipad",
"series60",
"windows ce",
"windows7phone",
"w7p",
"windows8phone",
"w8p",
"blackberry","
];
for (i in search_strings) {
if (uagent.search(search_strings[i]) > -1)
mobile = true;
}
return mobile;
}
if (detect()){
window.location = "mobile";
}