微信公众号页面问题-关闭按钮

场景:企业号应用A,首页加个按钮,点击直接关闭此页面,回到进入前的页面

解决:调用微信 WeixinJSBridge.call('closeWindow'); 代码如下:

复制代码
 1  handleReturn() {
 2             //关闭微信页面
 3             function weixinClosePage() {
 4                 if (typeof WeixinJSBridge == "undefined") {
 5                     if (document.addEventListener) {
 6                         document.addEventListener('WeixinJSBridgeReady', weixin_ClosePage, false);
 7                     } else if (document.attachEvent) {
 8                         document.attachEvent('WeixinJSBridgeReady', weixin_ClosePage);
 9                         document.attachEvent('onWeixinJSBridgeReady', weixin_ClosePage);
10                     }
11                 } else {
12                     weixin_ClosePage();
13                 }
14             }
15             function weixin_ClosePage() {
16                 WeixinJSBridge.call('closeWindow');
17             }
18             weixinClosePage()
19             // window.open("about:blank", "_self")
20             // window.close();
21         }
复制代码

posted on   鱼重生  阅读(222)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示