DeviceType: Difference between revisions
From OSE
Created page with "function getDeviceType() { const userAgent = navigator.userAgent.toLowerCase(); if (userAgent.includes('mobile') || userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) { return 'mobile'; } else if (userAgent.includes('tablet')) { return 'tablet'; } else { return 'desktop'; } }" |
No edit summary |
||
Line 7: | Line 7: | ||
} else { | } else { | ||
return 'desktop'; | return 'desktop'; | ||
} | }} | ||
} |
Revision as of 19:49, 30 May 2025
function getDeviceType() {
const userAgent = navigator.userAgent.toLowerCase(); if (userAgent.includes('mobile') || userAgent.includes('android') || userAgent.includes('iphone') || userAgent.includes('ipad')) { return 'mobile'; } else if (userAgent.includes('tablet')) { return 'tablet'; } else { return 'desktop'; }}