• 实现微信浏览器内打开App Store链接(已被和谐,失效了)


    微信浏览器是不支持打开App Store 页面的,不知道微信为什么这么做。比如你页面写 <a href=”http://itunes.apple.com/us/app/id399608199″>download</a> ,在微信浏览器点击链接是没有反应的,但是如果是其他的链接地址,比如百度那就没有问题

    后来我发现如果你在微信官方后台编辑图文,把原文链接写为: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再打开真正的页面。

    现在简单了,将页面的代码写为:<a href=”http://mp.weixin.qq.com/mp/redirect?url=http%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fid399608199%23rd”>download</a>,在微信浏览器内可以打开app store的地址了。

  • 相关阅读:
    学机器学习,不会数据分析怎么行——数据可视化分析(matplotlib)
    关于 tensorflow-gpu 中 CUDA 和 CuDNN 版本适配问题
    人工智能学习资料
    JAVA Socket通信 打造属于自己的网盘
    在 Windows 10 中使用 OpenAI Spinning Up
    【LeetCode】回文串专题
    【LeetCode】45.跳跃游戏2
    【LeetCode】23.最大子序和
    【LeetCode】3. 无重复字符的最长子串(典型滑动窗口)
    【LeetCode】202.快乐数
  • 原文地址:https://www.cnblogs.com/likwo/p/4867358.html
Copyright © 2020-2023  润新知