Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将文本中的空格转移到新页面?_Javascript_Jquery_Regex_Firefox - Fatal编程技术网

Javascript 如何将文本中的空格转移到新页面?

Javascript 如何将文本中的空格转移到新页面?,javascript,jquery,regex,firefox,Javascript,Jquery,Regex,Firefox,当用户单击“下一步”按钮时,来自两个单独文本框的数据将传输到新页面,但有%20代替了空格的位置。我怎样才能避免呢 来自originalpage.html的内联javascript $('#next').click(function(){ var coachFullName = $('#coach_txt_box').val(); var teamName = $('#team_txt_box').val(); if(!!coachFullName)

当用户单击“下一步”按钮时,来自两个单独文本框的数据将传输到新页面,但有%20代替了空格的位置。我怎样才能避免呢

来自originalpage.html的内联javascript

$('#next').click(function(){
        var coachFullName = $('#coach_txt_box').val();
        var teamName = $('#team_txt_box').val();
        if(!!coachFullName){
window.location.href = 'newpage.html?zip=' + coachFullName + teamName;
        } else {
            $('# coach_txt_box').watermark('please enter coach name',{className: 'watermarkError'});
        }
    });
来自newpage.html的内联javascript

function getParameterByName(name)
{
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.search);
    if(results == null)
        return "";
    else
        document.signupform.coach_and_team_name.value = results[1];
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}

getParameterByName('coach');

你应该用像这样的东西 用php或


不需要正则表达式来实现您想要的功能

出现%20的问题只发生在Firefox中。在IE中看起来还可以。通过哪种方法你可以在新页面中获得传输的文本…?@JohnMontague我认为这是由浏览器自动完成的,因为URI中不允许使用空格。浏览器和版本之间可能存在差异。。。