我的网址 print.html名称=本特利+永丰&安培; B = 1和C = 2
<script type='text/javascript'>
var name = (location.search.split('name=')[1]||'').split('&')[0];
document.getElementById("print_to").innerHTML = name;
</script>
我的HTML节目结果:Bentley + Foong
如何删除此&#34; +&#34;
谢谢。
答案 0 :(得分:0)
你会做一个非常简单的替换
var name = (location.search.split('name=')[1]||'').split('&')[0];
name = name.replace("+", " ");
答案 1 :(得分:0)
尝试此功能从URL
获取参数值 function __get_parameter_by_name(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}