Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H5 history.pushState 在微信内修改url后点击用safari打开/复制链接是修改之前的页面 #125

Closed
zrain opened this issue Dec 15, 2015 · 113 comments

Comments

@zrain
Copy link

@zrain zrain commented Dec 15, 2015

Hey, nice work guys.

看到你回答了 微信内 pushState 相关的问题,我这里做了一些小尝试

我使用 H5 history.pushState 在微信内修改url后,点击 “用safari打开”/“复制链接” 发现链接地址是修改之前的地址,不知道这种情况有没有遇到过。

@progrape

This comment has been minimized.

Copy link
Collaborator

@progrape progrape commented Dec 15, 2015

we got it~

@zrain

This comment has been minimized.

Copy link
Author

@zrain zrain commented Dec 15, 2015

补充一下:使用你的demo来看,pushState 修改了 url 在“用safari打开”时, safari里的url是修改后的url 。没有问题,但是我用 pushState 修改路径后, 在“用safari打开”时 ,safari里的url是修改前的url。使用“复制链接”功能也是如此。唯一的区别是我的url中没有“#”号

@bruceCzK

This comment has been minimized.

Copy link
Contributor

@bruceCzK bruceCzK commented Dec 17, 2015

这个应该是微信的BUG,所以SPA里面如果用了Html5Mode,到微信支付的页面时候要刷新下才行。

@zrain

This comment has been minimized.

Copy link
Author

@zrain zrain commented Dec 17, 2015

Thx 我现在 每个页面都刷新一下 否则分享页面 复制链接 和用Safari打开都会有问题 同样感谢您的回复 祝您工作愉快 期待微信的修复

发自我的 iPhone

在 2015年12月17日,14:16,Bruce Chen notifications@github.com 写道:

这个应该是微信的BUG,所以SPA里面如果用了Html5Mode,到微信支付的页面时候要刷新下才行。


Reply to this email directly or view it on GitHub.

@wb-yangxing

This comment has been minimized.

Copy link

@wb-yangxing wb-yangxing commented Apr 26, 2016

他监听的是hashchange, 不是pushState

@Hanruis

This comment has been minimized.

Copy link

@Hanruis Hanruis commented May 18, 2016

同样遇到类似的问题,@bruceCzK 在 SPA 里面使用 hash 的,在 IOS 下,也是需要刷新了才能 config 成功。然后如果需要频繁刷新的话, SPA 就失去意义了。求解。

@bruceCzK

This comment has been minimized.

Copy link
Contributor

@bruceCzK bruceCzK commented May 18, 2016

@Hanruis 我现在是每个页面都重新调用接口获取签名然后 config 一次,而且安卓和 iOS 的表现还不太一样。
比如同样从 /a 切换到 '/b',iOS 会认为 URL 确实变化了,需要重新注入配置信息,安卓就不需要,而且安卓上面不同机型内核还不一样,有些又是支持 pushState 的,总之挺分裂的。
另外 复制链接这东西,无解,只能在有些页面隐藏掉复制链接按钮

@Hanruis

This comment has been minimized.

Copy link

@Hanruis Hanruis commented May 18, 2016

@bruceCzK 确实是。
另外有一点挺矛盾的,一方面,jssdk 里面说到 config 的时候,hash 部分不需要加上。
然而用 hash 实现的 webapp, 在公众号设置的支付目录一般都是 www.mywebapp.com/#pay/ 这样的目录。使用在支付页面 config 的时候,需要把这个 hash 加上才能支付。(─.─|||,不然会报,这个 url 未注册。

然后在 IOS 下需要刷新之后,这个 config 才能成功。纠结。。

@bruceCzK

This comment has been minimized.

Copy link
Contributor

@bruceCzK bruceCzK commented May 18, 2016

@Hanruis 有关支付目录有个小窍门,井号前面加一个问号,目录就会只计算到问好前面最后一个斜杠,具体可以看我博文 https://awesome-bruce.me/2016/02/03/spa-zhong-wei-xin-zhi-fu-mu-lu-de-she-zhi/

@Hanruis

This comment has been minimized.

Copy link

@Hanruis Hanruis commented May 18, 2016

@bruceCzK woa,感谢!

@airyland

This comment has been minimized.

Copy link
Contributor

@airyland airyland commented May 18, 2016

@bruceCzK 因为微信客户端不同平台对history, hash的处理不同而且奇怪的实现真的浪费了好多时间,本来想做一个纯粹的单页面应用,用history,折腾到最后还是算了,直接用hash然后还是跳转到新页面去支付吧。然后因为router切换而出现的JSSDK config的问题直接就记录入口页面链接,当前页面链接,然后逐个试,只要出现wx.error, 就重新调用config。累感不爱,真希望微信能开个Repo来收集一下这些问题或者给个建议的处理方式。

顺便再提个问题如果能反馈给相关的同学就更好了,web开发工具对hash做了奇怪的处理:

输入这个地址打enter
http://localhost:6004/#!/a
url被处理成了这个样子,简直没法用。但是在js里进行hash设定又没问题。
http://localhost:6004/#!/%21/a

@progrape

This comment has been minimized.

Copy link
Collaborator

@progrape progrape commented May 18, 2016

@airyland Web 开发者工具的问题收到,近期修复

@J22Melody

This comment has been minimized.

Copy link

@J22Melody J22Melody commented Jul 22, 2016

求问这个问题什么时候能修复? T.T

@magicly

This comment has been minimized.

Copy link

@magicly magicly commented Aug 10, 2016

http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html 里说:
所有需要使用JS-SDK的页面必须先注入配置信息,否则将无法调用(同一个url仅需调用一次,对于变化url的SPA的web app可在每次url变化时进行调用,目前Android微信客户端不支持pushState的H5新特性,所以使用pushState来实现web app的页面会导致签名失败,此问题会在Android6.2中修复)。、

但是我们测试,发现6.3还是有问题啊。 iOS也有问题, 请问这个是bug么

@lzbSun

This comment has been minimized.

Copy link

@lzbSun lzbSun commented Aug 25, 2016

@magicly 我们也出现这个问题,你们解决了没有

@lzbSun

This comment has been minimized.

Copy link

@lzbSun lzbSun commented Aug 25, 2016

我们IOS是正常的 @magicly 就是安卓端微信不行

@Roeis

This comment has been minimized.

Copy link

@Roeis Roeis commented Sep 21, 2016

测试发现是x5内核就会出现pushstate问题,ios和Android都有这个问题。在X5里,url栏不会改变,微信都是6.3的版本

@BearJ BearJ closed this Sep 29, 2016
@duxiaofeng-github

This comment has been minimized.

Copy link

@duxiaofeng-github duxiaofeng-github commented Oct 24, 2016

@Roeis +1,微信是移动端的ie6果然不是浪得虚名。

@zlzdp

This comment has been minimized.

Copy link

@zlzdp zlzdp commented Nov 1, 2016

我也遇到这样的问题。history 修改后,微信中使用 safari 打开,url 中的参数全部丢失了。SPA 在微信中存在如此大的问题是我从来没有想过的。

@smalin

This comment has been minimized.

Copy link

@smalin smalin commented Dec 2, 2016

问题依然存在。所以 iphone 只加载一次 we.config(config), 安卓在每次 url 变化之后重新 wx.config(config)

@zhangjiayin

This comment has been minimized.

Copy link

@zhangjiayin zhangjiayin commented Dec 8, 2016

进入页面的时候config 所有需要的权限 试试? 以后在config 的时候忽略掉错误。强行调用!wx api

@mishe

This comment has been minimized.

Copy link

@mishe mishe commented Dec 27, 2016

问题依然存在,没有解决bug的期限吗?

@mishe

This comment has been minimized.

Copy link

@mishe mishe commented Dec 27, 2016

6.3.31貌似解决了,但为什么最新版的还是复现了?

@jiangfengming

This comment has been minimized.

Copy link

@jiangfengming jiangfengming commented Mar 20, 2017

bug又回来了,没人管吗?

@wuchangming

This comment has been minimized.

Copy link

@wuchangming wuchangming commented Mar 30, 2017

iOS 微信6.5.6版本。location.reload() 会导致通过Safari打开的按钮都消失了。。。。。

@asbai

This comment has been minimized.

Copy link

@asbai asbai commented Mar 31, 2017

现在最新的微信 iOS 版上确实有这个问题?何时解决?

@wuchangming

This comment has been minimized.

Copy link

@wuchangming wuchangming commented Mar 31, 2017

解决方案:url参数增加随机参数

function wxRefresh() {
    var replaceQueryParam = (param, newval, search) => {
        var regex = new RegExp('([?;&])' + param + '[^&;]*[;&]?');
        var query = search.replace(regex, '$1').replace(/&$/, '');

        return (query.length > 2 ? query + '&' : '?') + (newval ? param + '=' + newval : '');
    };

    window.location.replace(location.protocol +
        '//' +
        location.host +
        location.pathname +
        replaceQueryParam('_wxr_', new Date().getTime(), location.search) +
        location.hash);
};
// 执行
wxRefresh();
@xiaoxintang

This comment has been minimized.

Copy link

@xiaoxintang xiaoxintang commented May 7, 2019

直到2019-5-7问题还没修复

@janzhou

This comment has been minimized.

Copy link

@janzhou janzhou commented May 10, 2019

iOS 小程序web-view内的问题似乎修复了?raw h5 问题还在。求验证。

@w493189140

This comment has been minimized.

Copy link

@w493189140 w493189140 commented May 16, 2019

直到2019-5-16问题还没修复

@Johnson-huang

This comment has been minimized.

Copy link

@Johnson-huang Johnson-huang commented May 17, 2019

直到2019-5-17问题还没修复

@jinbiaode

This comment has been minimized.

Copy link

@jinbiaode jinbiaode commented May 27, 2019

直到2019-5-27问题还没修复

@9668596818ez

This comment has been minimized.

Copy link

@9668596818ez 9668596818ez commented May 29, 2019

直到2019-5-29问题还没修复

@xiaowang1314

This comment has been minimized.

Copy link

@xiaowang1314 xiaowang1314 commented Jun 29, 2019

2019-6-29问题依旧

@yulrosy

This comment has been minimized.

Copy link

@yulrosy yulrosy commented Jul 2, 2019

2019-7-2问题依旧

@lhf168

This comment has been minimized.

Copy link

@lhf168 lhf168 commented Jul 3, 2019

2019-7-3问题依旧 在ios微信“复制链接”,复制结果为初始页面链接

@lhf168

This comment has been minimized.

Copy link

@lhf168 lhf168 commented Jul 3, 2019

@微信APP开发大佬

@yuwanlin

This comment has been minimized.

Copy link

@yuwanlin yuwanlin commented Jul 10, 2019

2019.7.10 安卓9,微信7.0.4。使用pushState修改url后,在浏览器打开url上的参数会丢失。

@BruceCham

This comment has been minimized.

Copy link

@BruceCham BruceCham commented Jul 15, 2019

直至2019-07-15,问题还没解决

@xs528

This comment has been minimized.

Copy link

@xs528 xs528 commented Jul 31, 2019

直至2019-07-31,问题还没解决

@MuLoo

This comment has been minimized.

Copy link

@MuLoo MuLoo commented Aug 2, 2019

直至2019-08-02,问题还没解决。

@ZyanWlayor

This comment has been minimized.

Copy link

@ZyanWlayor ZyanWlayor commented Aug 6, 2019

直到2019-08-06,问题还没解决。

@nieyulin112

This comment has been minimized.

Copy link

@nieyulin112 nieyulin112 commented Aug 7, 2019

微信授权页面,地址栏拼接了code,立即分享,分享的页面是自定义的,结果分享出去的页面也是带有code,这样新用户点进来就会报错,大家有好的解决办法吗?

@lhf168

This comment has been minimized.

Copy link

@lhf168 lhf168 commented Aug 7, 2019

@nieyulin112

This comment has been minimized.

Copy link

@nieyulin112 nieyulin112 commented Aug 7, 2019

你应该把要分享的链接进行处理。不能直接取当前页面的url放作为分享url。------------------ 原始邮件 ------------------ 发件人: "nieyulin"notifications@github.com 发送时间: 2019年8月7日(星期三) 上午8:45 收件人: "Tencent/weui"weui@noreply.github.com; 抄送: "lhf168"1147678023@qq.com;"Comment"comment@noreply.github.com; 主题: Re: [Tencent/weui] H5 history.pushState 在微信内修改url后点击用safari打开/复制链接是修改之前的页面 (#125) 微信授权页面,地址栏拼接了code,立即分享,分享的页面是自定义的,结果分享出去的页面也是带有code,这样新用户点进来就会报错,大家有好的解决办法吗? — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

我删除了code还是不行,就是会自动带上code,在工具里调试是可以的,一到手机上就有问题了,分享出去的页面就是会带上code

@lhf168

This comment has been minimized.

Copy link

@lhf168 lhf168 commented Aug 7, 2019

@falost

This comment has been minimized.

Copy link

@falost falost commented Aug 7, 2019

@blinkJun

This comment has been minimized.

Copy link

@blinkJun blinkJun commented Aug 8, 2019

直到2019-08-08,问题还没解决。

@Grifree

This comment has been minimized.

Copy link

@Grifree Grifree commented Aug 20, 2019

直到2019-08-20,问题还没解决。

@xujunjie10

This comment has been minimized.

Copy link

@xujunjie10 xujunjie10 commented Aug 23, 2019

直到2019-08-23,问题还没解决。

@Ivy-Pei

This comment has been minimized.

Copy link

@Ivy-Pei Ivy-Pei commented Sep 6, 2019

直到2019-09-06,问题还没解决。

@proactivefly

This comment has been minimized.

Copy link

@proactivefly proactivefly commented Sep 10, 2019

直到2019-09-10 18:30,问题还没解决

@lqfxz520

This comment has been minimized.

Copy link

@lqfxz520 lqfxz520 commented Oct 21, 2019

直到2019-10-21 ,问题还没解决

@wsxgs

This comment has been minimized.

Copy link

@wsxgs wsxgs commented Oct 30, 2019

直到2019-10-30 ,问题还没解决

@five6002776

This comment has been minimized.

Copy link

@five6002776 five6002776 commented Nov 7, 2019

直到2019-11-7 ,问题还没解决

@yerxichen

This comment has been minimized.

Copy link

@yerxichen yerxichen commented Nov 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.