相关疑难解决方法(0)

在JavaScript中编码URL?

如何使用JavaScript安全地对URL进行编码,以便将其放入GET字符串?

var myUrl = "http://example.com/index.html?param=1&anotherParam=2";
var myOtherUrl = "http://example.com/index.html?url=" + myUrl;
Run Code Online (Sandbox Code Playgroud)

我假设你需要myUrl在第二行编码变量?

javascript url encoding

2392
推荐指数
14
解决办法
145万
查看次数

你什么时候应该使用escape而不是encodeURI/encodeURIComponent?

编码要发送到Web服务器的查询字符串时 - 何时使用escape()以及何时使用encodeURI()encodeURIComponent():

使用转义:

escape("% +&=");
Run Code Online (Sandbox Code Playgroud)

要么

使用encodeURI()/ encodeURIComponent()

encodeURI("http://www.google.com?var1=value1&var2=value2");

encodeURIComponent("var1=value1&var2=value2");
Run Code Online (Sandbox Code Playgroud)

javascript encoding query-string

1371
推荐指数
11
解决办法
45万
查看次数

标签 统计

encoding ×2

javascript ×2

query-string ×1

url ×1