JQuery Device Detector [Mobile Device / IPad / IPhone / Other]
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
fun();
});
</script>
<script>
function fun() {
var device = navigator.userAgent;
var checker = {
microsoft: device.match(/IEMobile/),
ipad: device.match(/(iPad)/),
iphone: device.match(/(iPhone)/),
blackberry: device.match(/BlackBerry/),
android: device.match(/Android/)
};
if (checker.microsoft){
alert("Microsoft");
}
else if(checker.ipad) {
alert("ipaD");
}
else if (checker.iphone){
alert("iphone...");
}
else if (checker.blackberry){
alert("BlackBerry");
}
else if(checker.android) {
alert("Android");
}
else {
alert("Unknown Device/Desktop .... ");
}
};
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
fun();
});
</script>
<script>
function fun() {
var device = navigator.userAgent;
var checker = {
microsoft: device.match(/IEMobile/),
ipad: device.match(/(iPad)/),
iphone: device.match(/(iPhone)/),
blackberry: device.match(/BlackBerry/),
android: device.match(/Android/)
};
if (checker.microsoft){
alert("Microsoft");
}
else if(checker.ipad) {
alert("ipaD");
}
else if (checker.iphone){
alert("iphone...");
}
else if (checker.blackberry){
alert("BlackBerry");
}
else if(checker.android) {
alert("Android");
}
else {
alert("Unknown Device/Desktop .... ");
}
};
</script>
</head>
<body>
</body>
</html>
No comments:
Post a Comment