关于 请求参数 传递时 参数字符串里面包含 特殊符号的 解决~

encodeURIComponent 用这个方法就可以了

是在做微信分享接口的时候 遇到的~~ 

例子 

function flightHandler0() {
    url = url + "?url=" + encodeURIComponent(window.location.href) + "&callback=flightHandler";
    // 创建script标签,设置其属性
   var script = document.createElement('script');
   script.setAttribute('src', url);
   // 把script标签加入head,此时调用开始
   document.getElementsByTagName('head')[0].appendChild(script);
}

要把当前地址当成参数传递时  可以先用 encodeURIComponent 处理一下~~

posted @ 2015-02-12 22:23  放羊的阿波罗  阅读(499)  评论(0编辑  收藏  举报