在后台调用了C#的Server.UrlEncode(url),然后get页面,前台javaScript调用decodeURI(url)得到的结果与编码之前的不一致?
解决方案 »
- JS判断浏览器为360浏览器
- 一个比较复杂的问题:关于闭包还有匿名函数的arguments
- 求一个非常复杂的表格特效:拖动排序,改变列宽,表头排序,上下移动行,隔行同色。在线等。
- 怎样让浏览器全屏
- 为什么<%=%> <%#%> 的结果不一样?
- 发一个模仿QQ用户信息提示的JS效果,请大家多提意见^_^
- 怎么让submit按钮在提交后不能再点??
- 请问为什么onload='if(parent.parent.document.ch.'+ee+'.value=="no"){parent.parent.document.ch.'+ee+'.value="ok";}'这个会出错!
- 有左右两个框架,如何在左框架里点击一个按钮,使右框架的表单FORM1提交
- 急!!!!!!!!!
- 登录 跳转
- js中怎样弹出提示框
结果是
"..%2fSvgFolder%2f1%2f20101103%2f1%e6%9c%ba%e7%bb%84EXTR+HTR%e7%b3%bb%e7%bb%9f%e7%94%bb%e9%9d%a2.svg"decodeURI("..%2fSvgFolder%2f1%2f20101103%2f1%e6%9c%ba%e7%bb%84EXTR+HTR%e7%b3%bb%e7%bb%9f%e7%94%bb%e9%9d%a2.svg")
结果是
"..%2fSvgFolder%2f1%2f20101103%2f1机组EXTR+HTR系统画面.svg"
function text_replace(text){
var l = text.length;
for (var i = 0; i < l; i++) {
if (text.charAt(i) == "%"){
if(text.charAt(i+1) == "2"){
if(text.charAt(i+2) == "3")text = text.replace("%23","#");
if(text.charAt(i+2) == "4")text = text.replace("%24","$");
if(text.charAt(i+2) == "6")text = text.replace("%26","&");//&&
if(text.charAt(i+2) == "B")text = text.replace("%2B","+");
if(text.charAt(i+2) == "C")text = text.replace("%2C",",");
if(text.charAt(i+2) == "F")text = text.replace("%2F","/");
}
if(text.charAt(i+1) == "3"){
if(text.charAt(i+2) == "F")text = text.replace("%3F","?");
if(text.charAt(i+2) == "B")text = text.replace("%3B",";");
if(text.charAt(i+2) == "D")text = text.replace("%3D","=");
if(text.charAt(i+2) == "A")text = text.replace("%3A",":");
}
if(text.charAt(i+1) == "4"){
if(text.charAt(i+2) == "0")text = text.replace("%40","@");
}
}
}
return text;
}
encode:function(text) {
var schars="!\"#$%&'()*+,/:;<=>?[]^`{|}~%",res=[],i=0,ch,c;
for(;i < text.length;i++) {
ch=text.charAt(i);
c=text.charCodeAt(i);
if(c >0x7E )
res[i]=encodeURI(ch);
else {
if(ch===" ")
res[i]="+"
else if(schars.indexOf(ch)===-1)
res[i]=ch;
else
res[i]="%"+c.toString(16)
}
}
return res.join("");
},
decode:function(text){
var res=[],i=0,ch,asc;
for(var i=0;i<text.length;i++){
ch= text.charAt(i);
if(ch == "+"){
res.push(" ");
}else if(ch=="%"){
asc = text.substring(i+1,i+3);
if(parseInt("0x"+asc)>0x7f){
res.push(decodeURI("%"+asc.toString()+text.substring(i+3,i+9).toString()) )
i+=8;
}else{
res.push(String.fromCharCode(parseInt("0x"+asc)));
i+=2;
}
}else{
res.push( ch);
}
}
return res.join("");
}
};