用JavaScript编码URL? - Encode URL in JavaScript?

问题:

How do you safely encode a URL using JavaScript such that it can be put into a GET string? 如何使用JavaScript安全地编码URL,以即可以将其放入GET字符串中? html

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
相关文章
相关标签/搜索