浏览器如何传递特殊参数#、+、%等字符????????? 是用js的escape方法 但是有个问题: %、#、+、&这四个字符并不能都会编码 其次escape方法后还要用unescape方法解码 这样是不是有点不合适呢???? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果自己定义一个函数 是否比较好,还是有点得不尝试呢 欢迎大家提点意见function swapParameter(swapData){ if (swapData == null) return null; while(swapData.indexOf("%") != -1) swapData = swapData.replace("%", "%25"); while(swapData.indexOf("#") != -1) swapData = swapData.replace("#", "%23"); while(swapData.indexOf("+") != -1) swapData = swapData.replace("+", "%2B"); while(swapData.indexOf("&") != -1) swapData = swapData.replace("&", "%26"); return swapData;}不需要解码同时实现编码的功能 可以吗 encodeURIComponentencodeURIComponent 方法将文本字符串编码为一个统一资源标识符 (URI) 的一个有效组件。encodeURIComponent(encodedURIString)必选的 encodedURIString 参数代表一个已编码的 URI 组件。decodeURIComponentdecodeURIComponent 方法返回统一资源标识符 (URI) 的一个已编码组件的非编码形式。decodeURIComponent(encodedURIString)必选的 encodedURIString 参数代表一个已编码的 URI 组件。<script language=javascript>var strs="fasodfasklfj&*^%^#)*(@^(&*#(@(#$&+"strs=encodeURIComponent(strs)document.write(strs)document.write("<br>")document.write(decodeURIComponent(strs))</script> 只要是url,好像是用escape函数后,都不用解码,得到的就是正确的数据 以前我的参数中有汉字时,用escape就好使 大神 来救~~ JS兼容性 表单内输入内容,DIV内相同的字就变为蓝色,其他的不变。 表格tr,应用 slideDown(); 如何通过JAVASCRIPT 访问后台数据啊 求一简单的javaScript验证 javascript是否可以提交服务器响应呢? 怎么用JS获取另外一个下页面中表单传过来的值?在线等急? 抢分问题? 百度地图api驾车路线经过多个途径点,怎么获取相邻两个地点的距离跟时间 判断的问题,急?? 求救,搞了两天。显示找不到对象。
{
if (swapData == null)
return null;
while(swapData.indexOf("%") != -1)
swapData = swapData.replace("%", "%25");
while(swapData.indexOf("#") != -1)
swapData = swapData.replace("#", "%23");
while(swapData.indexOf("+") != -1)
swapData = swapData.replace("+", "%2B");
while(swapData.indexOf("&") != -1)
swapData = swapData.replace("&", "%26");
return swapData;
}不需要解码同时实现编码的功能 可以吗
encodeURIComponent 方法
将文本字符串编码为一个统一资源标识符 (URI) 的一个有效组件。encodeURIComponent(encodedURIString)必选的 encodedURIString 参数代表一个已编码的 URI 组件。
decodeURIComponent
decodeURIComponent 方法
返回统一资源标识符 (URI) 的一个已编码组件的非编码形式。decodeURIComponent(encodedURIString)必选的 encodedURIString 参数代表一个已编码的 URI 组件。
<script language=javascript>
var strs="fasodfasklfj&*^%^#)*(@^(&*#(@(#$&+"
strs=encodeURIComponent(strs)
document.write(strs)
document.write("<br>")
document.write(decodeURIComponent(strs))
</script>