我希望将整个字符串'/image.htm?diskindex=0&diskcount=2&sortby=0&view=0&imagefilter=1&sizemore=1'
作为actiondownloadsingle.htm
的参数传递。
我尝试使用函数encodeURI来编码字符串,但是我失败了,我无法在服务器客户端获得参数origurl的正确值,我该怎么办?谢谢!
$('.CssDownloadSingle').click(function () {
var fileName = GetHiddenFilename(this);
var origurl ='/image.htm?diskindex=0&diskcount=2&sortby=0&view=0&imagefilter=1&sizemore=1'
location.href = "actiondownloadsingle.htm?origurl=" +encodeURI(origurl);
});
答案 0 :(得分:1)
尝试使用encodeURIComponent
将其编码为参数值
var origurl ='/image.htm?diskindex=0&diskcount=2&sortby=0&view=0&imagefilter=1&sizemore=1';
alert(
"encodeURIComponent: actiondownloadsingle.htm?origurl=" + encodeURIComponent(origurl) + "\r\n"
+ "encodeURI: actiondownloadsingle.htm?origurl=" + encodeURI(origurl)
);