0
私はモバイル/タブレット互換のレイアウトを持っていないので、モバイル/タブレット/ Linux端末から来たユーザーは、「出る」ページを表示します。しかし、ユーザーがPCのブラウザIEの古い、IEのエッジ、Safari、Google Chrome、Firefox、Opera、Midoriなどから来ている場合は、それは許可されています。JavaScriptがWindows 10をプロ、IE11をモバイルまたはタブレットとして扱うのはなぜですか?
なぜ私はis_pc
をfalse
としても、ブラウザはPCとIE11でしたか?
window.onload = userAgentDetect;
var is_pc = true;
function userAgentDetect() {
if(window.navigator.userAgent.match(/Mobile/i)
|| window.navigator.userAgent.match(/iPhone/i)
|| window.navigator.userAgent.match(/iPod/i)
|| window.navigator.userAgent.match(/IEMobile/i)
|| window.navigator.userAgent.match(/Windows Phone/i)
|| window.navigator.userAgent.match(/Android/i)
|| window.navigator.userAgent.match(/BlackBerry/i)
|| window.navigator.userAgent.match(/webOS/i)) {
document.body.className+=' mobile';
is_pc = false;
get_out_from_here();
}
if(window.navigator.userAgent.match(/Tablet/i)
|| window.navigator.userAgent.match(/iPad/i)
|| window.navigator.userAgent.match(/Nexus 7/i)
|| window.navigator.userAgent.match(/Nexus 10/i)
|| window.navigator.userAgent.match(/KFAPWI/i)) {
document.body.className-=' mobile';
document.body.className+=' tablet';
is_pc = false;
get_out_from_here();
}
}
あなたがそれをデバッグする場合は、あなたの答えを得る必要があります... 'にconsole.log(window.navigator.userAgent)' –
いただきまし特徴検出と間違っていますか? /または反応しやすいウェブサイト?.. usageAgentをチェックすることは悪い習慣であることを意味し、とにかくいつでも偽装することができます。 – Keith
Sir、window.navigator.userAgent、 'Mozilla/5.0(Windows NT 10.0; WOW64; Trident/7.0; Touch; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729 ; .NET CLR 3.5.30729; Tablet PC 2.0; rv:11.0)Geckoのように – YumYumYum