-
-
Save hristiank/e892e6c74a3e97850e2cbfe5e0f3f768 to your computer and use it in GitHub Desktop.
Detect Device (Desktop/Mobile) & Write to a Hidden Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function deviceDetect() { | |
var w = Math.max(document.body.offsetWidth, document.documentElement.offsetWidth); | |
return (w > 600) ? 'desktop': 'mobile'; | |
}; | |
$('#device').val(deviceDetect()); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment