Html Form Submit appends + (plus) in URL params

我的梦境 提交于 2019-12-12 05:38:47

问题


I am having a simple form following is the code

<form action="search.html" method="get" accept-charset="utf-8" id="search-within-form"">
    <input type="hidden" name="within" id="within" value="">
    <input type="text" name="q" value="" id="search-within" autocomplete="off" class="search-within-results inactive" title="">
    <input type="submit"/>
</form>

I am entering test data for search in the field and click submit, in the URL I see is

/search.html?within=&q=test+data+for+search

But I need the url to be like tis

/search.html?within=&q=test data for search

I know this can be done by using java script form submit etc.. I like to know is there some way I can achieve this using html?

Thanks in advance.


回答1:


Your URL will never display that way in a browser. Either the text will be seperated by those '+' characters or it will be seperated by '%20's. Is there a reason you need the URL to display in that fashion? Ultimately it comes down to how the browser displays the URL in the address bar. '%20' is code for a space. You might be able to develop a browser extension that would make them display with the spaces, but that sounds pretty terrible to me.




回答2:


Why don't you clean the text at the place you retrieve the value from the form ? Is there any reason why you can't do that ?



来源:https://stackoverflow.com/questions/15417976/html-form-submit-appends-plus-in-url-params

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!