ios app 解決微信掃二維碼不能跳轉問題


<script>
(function(){

// Setup GA
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-35169517-1', 'jianshu.com');

// Setup redirect flag
var Maleskine = {
href: '/apps',
search: location.search,
redirected: false,

redirect: function() {
if (Maleskine.redirected) return;

redirected = true;
// window.location.href = Maleskine.href;
window.location.href = Maleskine.href;
},

route: function() {
var ua = navigator.userAgent.toLowerCase();
var defaultBrowser;

if (/iphone|ipad|ipod/.test(ua)) {

// This is iOS.
platform = 'ios';
defaultBrowserName = ' Safari ';

if (/micromessenger|qq|mqqbrowser/.test(ua)) {
// In Weixin, go to QQ yingyongbao.
Maleskine.href = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.jianshu.haruki';
} else {
// Not in Weixin, go to AppStore directly.
Maleskine.href = "https://itunes.apple.com/cn/app/jian-shu/id888237539?ls=1&amp;mt=8";
}

ga('set', 'page', '/download/hugo' + Maleskine.search);
ga('send', 'pageview');
// setTimeout(Maleskine.redirect, 2000);

Maleskine.redirect();
} else if (/android/.test(ua)) {

// This is android.
platform = 'android';
defaultBrowserName = '瀏覽器';

if (/micromessenger/.test(ua)) {
// In Weixin, go to QQ yingyongbao.
Maleskine.href = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.jianshu.haruki';
} else {
Maleskine.href = 'http://downloads.jianshu.io/apps/haruki/JianShu-1.7.5.apk';
}
ga('set', 'page', '/download/haruki' + Maleskine.search);
ga('send', 'pageview');
// setTimeout(Maleskine.redirect, 2000);

Maleskine.redirect();
} else if (/windows phone|blackberry/.test(ua)) {
// This is other mobile system.
platform = 'other'
ga('set', 'page', '/download/other' + Maleskine.search);
ga('send', 'pageview');
alert('抱歉,我們暫沒有推出您手機系統對應的應用。');
location.href = '/';
} else {
platform = 'none'
ga('send', 'pageview');
location.href = '/apps';
}

// if (platform == 'ios') {
// var div = document.createElement('div');
// div.style.clear = 'both';
// div.appendChild(document.createTextNode('正在跳轉中···若您正在微信中無法跳轉,請點右上角的「···」按鈕,選擇「在' + defaultBrowserName + '中打開」即可正常跳轉噢~'));
// document.body.appendChild(div);
// div = document.createElement('div');
// div.style.float = 'right';
// div.appendChild(document.createTextNode('——— 簡書團隊'));
// document.body.appendChild(div);
// } else if (platform == 'android') {
// if (defaultBrowserName && /micromessenger/.test(ua)) {
// var div = document.createElement('div');
// div.style.clear = 'both';
// div.appendChild(document.createTextNode('正在跳轉中···若您正在微信中無法跳轉,請點右上角的「···」按鈕,選擇「在' + defaultBrowserName + '中打開」即可正常跳轉噢~'));
// document.body.appendChild(div);
// div = document.createElement('div');
// div.style.float = 'right';
// div.appendChild(document.createTextNode('——— 簡書團隊'));
// document.body.appendChild(div);
// }
// }
},
};

// GO!
Maleskine.route()
})()
</script>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM