从全名Aweber中删除%20

时间:2014-05-28 08:51:19

标签: javascript wordpress aweber

将变量从Aweber传递到wordpress谢谢页面 - 但名称如下所示: 姓名%20Lastname

使用的代码

    <script type="text/javascript">
 var formData = function() {  var query_string = (location.search) ? ((location.search.indexOf('#') != -1) ? location.search.substring(1, location.search.indexOf('#')) : location.search.substring(1)) : '';  
var elements = [];  
if(query_string) {     
    var pairs = query_string.split("&");     
    for(i in pairs) {     
        if (typeof pairs[i] == 'string') {           
            var tmp = pairs[i].split("=");           
            var queryKey = unescape(tmp[0]);           
            queryKey = (queryKey.charAt(0) == 'c') ? queryKey.replace(/s/g, "_") : queryKey;   
            elements[queryKey] = unescape(tmp[1]);      
             }    
       } 
 }  
return {     
    display: function(key) {         
        if(elements[key]) {           
             document.write(elements[key]);         
         } 
         else {         
               document.write("<!--If desired, replace everything between these quotes with a default in case there is no data in the query string.-->");          
          }     
  }   
} 
}
(); </script>

then
    <script>// <![CDATA[
formData.display('fullname')
// ]]></script>

试图       decodeURI(formData.display( “全名”)) 但它不起作用??? 我搜索和搜索,无法弄明白 - 请任何人帮忙??? 感谢。

1 个答案:

答案 0 :(得分:1)

我猜它是Wordpress插件的一部分,所以你只想要一个正确的修复:)

尝试更换此部分:

return {  
    display: function(key) {         
        if(elements[key]) {           
            document.write(elements[key]);         
        } else {         
            document.write("<!--If desired, replace everything between these quotes with a default in case there is no data in the query string.-->");          
        }     
    }
}

有了这个:

return {
    display: function(key) {         
        if(elements[key]) {           
            document.write(decodeURIComponent(elements[key]));  
        } else {         
            document.write("<!--If desired, replace everything between these quotes with a default in case there is no data in the query string.-->");          
        }     
    }
}