今天早上刚到公司,就收到反馈说公司前端页面的下载按钮在 iOS 7 的微信内置浏览器里面点击无效,经过确认之后,前端代码是正常的,问题出在了微信上,然后谷歌之,原来腾讯在***。
是 BUG 还是刻意为之?
最新版微信在所有开放的 webview(网页界面)里禁止了通过链接打开本地 app 或跳转到 app store,只有自家使用的 webview 能够打开 app 或跳转 app store。而且这种做法不像是 bug 所致,而是刻意为之。
可能的用意:微信是一个重要的互联网入口和应用入口,但是微信为了自家利益,需要控制入口和流量,进而加强对公共帐号和第三方应用的控制,打击竞争对手
该怎么办呢?
经过讨论之后,我们发现微信内置浏览器右上角的跳转按钮“在 Safari 中打开”可以间接的跳转 App Store ,所以最终我们的解决方案是如果是 iOS 的微信内置浏览器,点击按钮后,用弹出提示的方法来取代直接跳转。
效果如下图所示:
前端实现
index.html
1
2
3
4
5
<div id ='popweixin' >
<div class ='tip top2bottom animate-delay-1' >
<img src ='/static/img/wechat_appstore_popup.jpg' />
</div >
</div >
app.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#popweixin {
width :100% ;
height :100% ;
overflow :hidden;
position :fixed;
z-index :1000 ;
background :rgba (0 ,0 ,0 ,.5 );
top :0 ;
left :0 ;
display :none;
}
#popweixin .tip {
width :100% ;
background :#fff ;
z-index :1001 ;
}
.top2bottom {
-webkit-animation :top2bottom 1.2s ease;
-moz-animation :top2bottom 1.2s ease;
-o-animation :top2bottom 1.2s ease;
animation :top2bottom 1.2s ease;
-webkit-animation-fill-mode :backwards;
-moz-animation-fill-mode :backwards;
-o-animation-fill-mode :backwards;
animation-fill-mode :backwards
}
.animate-delay-1 {
-webkit-animation-delay :1s ;
-moz-animation-delay :1s ;
-o-animation-delay :1s ;
animation-delay :1s
}
@-webkit-keyframes top2bottom {
0% {
-webkit-transform :translateY (-300px );
opacity :.6
}
100% {
-webkit-transform :translateY (0px );
opacity :1
}
}@keyframes top2bottom {
0% {
transform :translateY (-300px );
opacity :.6
}
100% {
transform :translateY (0px );
opacity :1
}
app.js
1
2
3
4
5
6
7
8
function a ( ){
var ua = navigator.userAgent .toLowerCase ();
if (/iphone|ipod/ .test (ua)) {
if (/micromessenger/ .test (ua)){
document .getElementById ("popweixin" ).style .display = "block" ;
}
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
2012-03-17 Android自动更新代码
2012-03-17 Android应用开发之(你必须知道的“文件上传时显示进度的
2012-03-17 Android HttpClient上传文件与Httpconnection知识小结
2012-03-17 Layout_weight实践效果小结
2012-03-17 浅谈Android五大布局(一)——LinearLayout、FrameLayout和AbsoulteLayout
2012-03-17 android 遮罩层效果
2012-03-17 [Android实例] 天天动听 悬浮歌词(迷你歌词)效果解读