MobileDeviceDetection
Get the Device which visit your Website
by Konstantin Heinrich
HTML
<div id="mobile" class="mobile"></div>
<div id="desktop" class="desktop">
<h2>This is a very simple way to detect a mobile device</h2>
</div>
CSS
.mobile {
background-color:lightblue;
color:white;
width:100%;
height:100%;
}
.desktop {
background-color:lightgreen;
color:white;
width:100%;
height:100%;
}
JavaScript
var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android)/);
if (isMobile == null) {
isMobile = "Desktop/Laptop";
$('#desktop').append('<h1>Welcome: ' + isMobile + '</h1>');
$('#mobile').hide();
} else {
$('#mobile').append('<h1>Welcome: ' + isMobile + '</h1>');
alert("Willkommen bei JSFiddle \n "+ isMobile);
$('#desktop').hide();
}