Use navigator to get information of device.
Code:
<script>
var _device = navigator.userAgent;
var isMobile = _device.indexOf("Mobile") > 0;
var isAndroid = _device.indexOf("Android") > 0;
var isPad = _device.indexOf("iPad") > 0;
var isiPhone = _device.indexOf("iPhone") > 0;
if(isMobile && !isPad){
// device is mobile
if(isiPhone){
// device is iPhone
} else if(isAndroid){
// device is Android
}
} else if(isPad){
// device is iPad
} else {
// device is PC
}
</script>
No comments :
Post a Comment