当用户单击“下一步”按钮时,来自两个单独文本框的数据将被传输到新页面,但有 %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');