實現微信瀏覽器內打開App Store連接(已被和諧,失效了)

微信瀏覽器是不支持打開App Store 頁面的,不知道微信爲何這麼作。好比你頁面寫 <a href=」http://itunes.apple.com/us/app/id399608199″>download</a> ,在微信瀏覽器點擊連接是沒有反應的,可是若是是其餘的連接地址,好比百度那就沒有問題ajax

 

後來我發現若是你在微信官方後臺編輯圖文,把原文連接寫爲:http://itunes.apple.com/us/app/id399608199 ,那就能夠打開了,發現微信頁面的「查看原文」是一個function,以下瀏覽器

 

function viewSource() {
var redirectUrl = sourceurl.indexOf('://') < 0 ? 'http://' + sourceurl : sourceurl;
//redirectUrl = http://itunes.apple.com/us/app/id399608199
redirectUrl = 'http://' + location.host + '/mp/redirect?url=' + encodeURIComponent(sourceurl);
//此處是關鍵,redirectUrl = http://mp.weixin.qq.com/mp/redirect?url=http%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fid399608199%23rd
var opt = {
url: '/mp/advertisement_report' + location.search + '&report_type=3&action_type=0&url=' + encodeURIComponent(sourceurl) + '&uin=' + uin + '&key=' + key + '&__biz=' + biz + '&r=' + Math.random(),
type: 'GET',
async: !1
};
return tid ? opt.success = function (res) {
try {
res = eval('(' + res + ')');
} catch (e) {
res = {
};
}
res && res.ret == 0 ? location.href = redirectUrl : viewSource();
}
: (opt.timeout = 2000, opt.complete = function () {
location.href = redirectUrl;
}),
ajax(opt),
!1;
}

  

真正的url是:http://mp.weixin.qq.com/mp/redirect?url=http%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fid399608199%23rd微信

看來微信容許打開mp.weixin.qq.com這個host下的網頁,而後用js再打開真正的頁面。app

如今簡單了,將頁面的代碼寫爲:<a href=」http://mp.weixin.qq.com/mp/redirect?url=http%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fid399608199%23rd」>download</a>,在微信瀏覽器內能夠打開app store的地址了。dom

相關文章
相關標籤/搜索