开发者

Handling difference between strings returned in history change handler

开发者 https://www.devze.com 2023-02-15 23:03 出处:网络
I\'ve got an app that receives urls after the # sign and responds to them with a History ValueChangeHandler.Serious problem: the urls are escaped differently on different browsers.

I've got an app that receives urls after the # sign and responds to them with a History ValueChangeHandler. Serious problem: the urls are escaped differently on different browsers.

For exampl开发者_Go百科e, when I go to #riley%2Blark%40gmail.com, Chrome sends my ValueChangeHandler riley%2Blark%40gmail.com while FireFox sends riley+lark@gmail.com. This is a terrible difference if I want to run URL.decodeQueryString on them because I'll end up with an extra space in Firefox.

How can I handle this, short of writing separate implementations for different browsers?


I can think of two possible solutions:

  1. U could try adding another parameter to the token so that the token was of the for #riley%2Blark%40gmail.com/%2B-a-space on receiving the token, check the second part of the token. If the second part contains a %2B, urldecode the token. else replace '+' with

  2. You can also try using Location.hash through JSNI. I reckon the results ought to be uniform.

0

精彩评论

暂无评论...
验证码 换一张
取 消