標籤:
摘自:今日頭條
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>app下載</title> <script type="text/javascript"> // 擷取終端相關資訊 var Terminal = { // 辨別移動終端類型 platform: function() { var u = navigator.userAgent, app = navigator.appVersion; return { // android 終端 或uc瀏覽器 android: u.indexOf(‘Android‘) > -1 || u.indexOf(‘Linux‘) > -1, // 是否為iPhone 或 QQHD瀏覽器 iPhone: u.indexOf(‘iPhone‘) > -1, // 是否 iPad iPad: u.indexOf(‘iPad‘) > -1 }; }(), // 辨別移動終端的語言: zh-ch、en-us、ko-kr、ja-jp ... language: (navigator.browserLanguage || navigator.language).toLowerCase() } // 根據不同的終端,跳轉到不同的地址 var theUrl = ‘預設‘; if (Terminal.platform.android) { // 安卓 theUrl = ‘此次填寫安卓‘ } else if (Terminal.platform.iPhone) { // 蘋果 theUrl = ‘蘋果‘; } else if (Terminal.platform.iPad) { // 還可以通過Language,區分多國語言版 switch (Terminal.language) { case ‘en-us‘: // 你的iPad APP (英文版) 對應: APP Store地址 theUrl = ‘ipad‘; break; case ‘ko-kr‘: // 你的iPad APP (韓語版) 對應: APP Store地址 theUrl = ‘‘; break; case ‘ja-jp‘: // 你的iPad APP (日文版) 對應: APP Store地址 theUrl = ‘‘; break; default: // 你的iPad APP (中文-預設) 對應: APP Store地址 theUrl = ‘‘; } } location.href = theUrl; </script></head><body></body></html>
app下載——js裝置判斷