find_str: 查找的字符串

r_str: 代替的字符

t_str: 代替为啥

function replace(find_str, r_str, t_str) {
var b = find_str.split(r_str);
find_str = "";
for (var c in b) {
if (c != 0) {
find_str = t_str+b[c]+find_str;
} else {
find_str = b[c]+find_str;
}
}
return find_str;
}

比如,Flash打开的网址里面 # 和 , 之类的符号不能传递到浏览器,可以用escape进行转换:将参数转换为字符串,并以 URL 编码格式进行编码,在这种格式中,将所有非字母数字的字符都转义为 % 十六进制序列。

url="http://mccannmsnbjafa.allyes.com/main/adfclick?db=mccannmsnbjafa&bid=215,212,6&cid=198,5,1&sid=429&advid=1&camid=6&show=ignore&url=http://www.msn.com.cn";
url=replace(url,"#",escape("#"));
url=replace(url,",",escape(","));
//当然,把需要转换的字符都转换就好了
getURL(url,"_blank");

出错例子:

http://localhost/test.php?i=d11,2,33 getURL之后得到:http://localhost/test.php?i=d1

http://localhost/test.php?i=d,2,33 getURL之后得到:http://localhost/test.php?i=




原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐