问题
I need to make URL from some custom string values dynamically. I have doubt on "encodeURIComponent(string)" function whether it has cross browser issues does anyone experienced trouble with this function(I am not using any JS libraries)?
回答1:
encodeURIComponent
works as advertised in a cross-browser fashion. Use it in preference to escape
.
回答2:
Go for it. This is exactly what encodeURIComponent is for and it's well-supported across browsers. I've never heard of a serious issue with it on any major implementation.
来源:https://stackoverflow.com/questions/4407599/does-anyone-have-experienced-cross-browser-issues-with-encodeuricomponentstrin