Skip to content

Instantly share code, notes, and snippets.

@skylying
Created March 13, 2018 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skylying/a77ddbafb3d179b4001fbe3b81567e0a to your computer and use it in GitHub Desktop.
Save skylying/a77ddbafb3d179b4001fbe3b81567e0a to your computer and use it in GitHub Desktop.
Detect mobile Platform
<a class="btndefault" onclick="iosButton();" >下载</a></li>
function iosButton(){
//分辨是哪個裝置
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终端
if(isiOS) {
//紀錄下載
gtag('event', 'click', {'event_category':'click_ios_installation'});
window.location.replace(data_ios);
}else{
success_msg_show('请使用ios装置点击此连结');
if($(window).width() < 768){
alert('目前尚未提供Android版本,请用ios装置点击下载');
}
}
} // end of iosButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment