使用URL填写Form%20问题

时间:2016-09-29 17:58:16

标签: javascript jquery html

我正在使用网站网址预先填写html表单。

但是,如果我的网址是test.test.uk/test?notes=hello world

broswer把它变成了test.test.uk/test?notes=hello%20world,应该这样!

作为回报,将“hello%20world”输入我的表格

无论如何在javascript或html中我可以改变这个问题。

请考虑我是超级菜鸟。

我将如何正确使用此功能?

当前方法尝试用于从URL中删除%20。嵌入在每页的页脚中<脚本>标签

$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=       ([^&#]*)').exec(window.location.href);
if (results==null){
   return null;
}
else{
   return results[1] || 0;
}

}

1 个答案:

答案 0 :(得分:2)

您可以使用decodeUriComponent从文本中删除URI编码。

以下是一些文档的链接:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent

相关问题