问题:
How do you safely encode a URL using JavaScript such that it can be put into a GET string? 如何使用JavaScript安全地编码URL,以便可以将其放入GET字符串中?
var myUrl = "http://example.com/index.html?param=1&anotherParam=2";
var myOtherUrl = "http://example.com/index.html?url=" + myUrl;
I assume that you need to encode the myUrl variable on that second line? 我假设您需要在第二行编码myUrl变量?
解决方案:
参考一: https://stackoom.com/question/1Oau/用JavaScript编码URL参考二: https://oldbug.net/q/1Oau/Encode-URL-in-JavaScript
来源:oschina
链接:https://my.oschina.net/stackoom/blog/3212217
