0
什么是最好的方式将URL附加到查询字符串在JavaScript中?我意识到它需要被编码。编码的URL,所以它可以发送通过GET
我遇到过encodeURIComponent()
函数,它看起来像我想要的东西。我只是不确定它是否适合这种任务。
用法示例:
var someURL = encodeURIComponent("http://stackoverflow.com/questions/ask?name=.hil#");
var firstURL = "www.stackoverflow.com/questions?someurl="
firstURL+someURL;
是encodeURIComponent将提供正确的编码。 –
encodeURIComponent是此功能的正确功能。 – Gerfried