Quantcast
Channel: web development tutorials » Html
Viewing all articles
Browse latest Browse all 12

Detect mobile browser with javascript

$
0
0

Detect mobile web browsers with Javascript.

HTML5 is making the web platform more powerful in a number of different areas. All the Smaprt phones come up with this HTML5 and CSS3 browsers . It is the easy medium to reach the mobile users as HTMl5 has almost all features that mobile native apps have. Now a day all the web site owners want to be their websites need to compatible with these smartphones.

unfortunatley these mobile browsers doesn’t have all the features as desktop browsers such as large screens,mouse and other hardware specifications. Most of the times we get a situation where our web applications must be optimized differently from the mobile and desktop. For this we need to detect the user is viewing our website from the desktop browser or mobile browser.

Here is a small Javscript snippet that usefull to detect almost modern mobile devices based on their mobile OS( operating systems).

if(navigator.userAgent.match(/Android|webOS|iPhone|iPod|BlackBerry|iPad/i)){
alert("Yea, you are on mobile browser");
}else {
alert("Yea, you are on desktop browser");
}

Viewing all articles
Browse latest Browse all 12

Trending Articles