0

将变量从 Aweber 传递到 wordpress 感谢页面 - 但是名称显示如下:firstname%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("fullname")) 但它不起作用???我已经搜索和搜索并无法弄清楚 - 请任何人帮助???谢谢。

4

1 回答 1

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.-->");          
        }     
    }
}
于 2014-05-28T09:27:04.343 回答