How to replace a space in a URL in JavaScript?

前端 未结 2 1056
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 11:33

These are the 2 relevant lines from a function written in JavaScript:

var v_depttime = document.getElementById(\"EDDepttime\").value ;
url = url+\"?select_bn         


        
相关标签:
2条回答
  • 2020-12-11 12:20

    Use encodeURIComponent:

    url = url +
      "?select_bno=" + encodeURIComponent(v_busno) +
      "&select_depttime=" + encodeURIComponent(v_depttime);
    
    0 讨论(0)
  • 2020-12-11 12:32

    Use encodeURI or encodeURIComponent.

    0 讨论(0)
提交回复
热议问题