HTML表单提交在URL参数中附加+(加号) [英] Html Form Submit appends + (plus) in URL params

查看:888
本文介绍了HTML表单提交在URL参数中附加+(加号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的表单,下面是代码:

 < form action =search.htmlmethod =获取接受字符集=utf-8id =search-within-form> 
< input type =hiddenname =withinid =withinvalue => ;
< input type =textname =qvalue =id =search-withinautocomplete =offclass =search-within-results inactivetitle =>
< input type =submit/>
< / form>

我在字段中输入 搜索测试数据 ,然后点击提交,我看到的URL是

< blockquote>

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


但我需要的网址是像


/search.html?within=&q=test搜索数据


我知道这可以通过使用java脚本表单提交等来完成。我想知道有什么方法可以使用html来实现这一点吗?



在此先感谢您。

解决方案

您的网址永远不会在浏览器中显示。这些文字可能会被这些'+'字符分隔,或者它会被'%20'分隔。是否有理由需要URL以这种方式显示?最终归结为浏览器如何在地址栏中显示网址。 '%20'是一个空格的代码。您可能可以开发一个浏览器扩展程序,让它们显示空格,但这对我来说听起来很糟糕。


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.

解决方案

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.

这篇关于HTML表单提交在URL参数中附加+(加号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆