問題:
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