Created
August 12, 2012 01:06
-
-
Save ianthekirkland/3328565 to your computer and use it in GitHub Desktop.
Browser & Device detection
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
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> | |
<title>YOUR COMPANY</title> | |
<link media="all" rel="stylesheet" type="text/css" href="css/all.css"> | |
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script> | |
<script type="text/javascript" src="js/jquery.main.js"></script> | |
<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="css/ie.css" /><![endif]--> | |
<script type="text/javascript">//<![CDATA[ | |
var mobi = ['android', 'blackberry', 'ipad', 'safari']; | |
var midp = ['blackberry', 'symbian']; | |
var ua = navigator.userAgent.toLowerCase(); | |
if ((ua.indexOf('midp') != -1) || (ua.indexOf('mobi') != -1) || ((ua.indexOf('ppc') != -1) && (ua.indexOf('mac') == -1)) || (ua.indexOf('webos') != -1)) { | |
document.write('<link rel="stylesheet" href="css/allmobile.css" type="text/css" media="all"/>'); | |
if (ua.indexOf('midp') != -1) { | |
for (var i = 0; i < midp.length; i++) { | |
if (ua.indexOf(midp[i]) != -1) { | |
document.write('<link rel="stylesheet" href="css/' + midp[i] + '.css" type="text/css"/>'); | |
} | |
} | |
} | |
else { | |
if ((ua.indexOf('mobi') != -1) || (ua.indexOf('ppc') != -1) || (ua.indexOf('webos') != -1)) { | |
for (var i = 0; i < mobi.length; i++) { | |
if (ua.indexOf(mobi[i]) != -1) { | |
if ((mobi[i].indexOf('blackberry') != -1) && (ua.indexOf('6.0') != -1)) { | |
document.write('<link rel="stylesheet" href="css/' + mobi[i] + '6.0.css" type="text/css"/>'); | |
} | |
else { | |
document.write('<link rel="stylesheet" href="css/' + mobi[i] + '.css" type="text/css"/>'); | |
} | |
break; | |
} | |
} | |
} | |
} | |
} | |
//]]> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment