用JavaScript编码URL?

戏子无情 提交于 2020-03-27 07:47:50

3 月,跳不动了?>>>

问题:

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!