为什么80%的码农都做不了架构师?>>>
<script type="text/javascript">
//判断访问终端
var browser={versions:function(){var u = navigator.userAgent, app = navigator.appVersion;return {trident: u.indexOf('Trident') > -1, //IE内核presto: u.indexOf('Presto') > -1, //opera内核webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器iPad: u.indexOf('iPad') > -1, //是否iPadwebApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)qq: u.match(/\sQQ/i) == " qq" //是否QQ};}(),language:(navigator.browserLanguage || navigator.language).toLowerCase()
}
</script>
下面是一个应用的例子,是否在Android,或者ios 调用起百度地图
<html>
<head>
</head><script type="text/javascript">
function jump(){
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
//alert('是否是Android:'+isAndroid);
//alert('是否是iOS:'+isiOS);if (isAndroid)
{
window.location.href="bdapp://map/navi?location=34.264642646862,108.95108518068&type=BLK&src=webapp.navi.yourCompanyName.yourAppName"
}else{window.location.href="baidumap://map/direction?origin=34.264642646862,108.95108518068&destination=40.007623,116.360582&mode=driving&src=webapp.navi.yourCompanyName.yourAppName" }
}
</script><body>
<img src="menu_daohang.png" class="daohang" onClick="jump()"/></body>
</html>