JavaScriptでユーザーエージェントを用いてスマートフォン、タブレットデバイスのみ検知する方法。
Mozillaのサイトによると、"Mobi"の文字で検知することが推奨されている。
例:
if (navigator.userAgent.match(/Mobi/g)) { …}
*gはglobalに検索。一番初めにヒットした検索文字だけでなく、対象の全ての文字を検索
Browser detection using the user agent string (UA sniffing) - HTTP | MDN
Along with every request to a server, browsers include a User-Agent HTTP header with a value called a user agent (UA) string.
This string is intended to identif...

コメント