对表单中的文本进行编码...有什么解决方案吗?
我有一个非常简单的 HTML 表单,它将获取文本框的值并创建一个 URL。 这是我的表单:
<form id="searchForm" method="GET" action="http://searchserver/results.aspx target="_blank">
<input type="text" name="p" size="18" maxlength="256" value="hello world"/>
</form>
如您所见,当按 Enter 键时,它将值发送到新浏览器,其 url 为:“http://searchserver/results.aspx?p=hello+world”
有没有办法强制此处的加号 (+) 是否插入到 %20 字符中?所以它会是:“http://searchserver/results.aspx?p=hello*%20*world”
谢谢
I do have a very simple HTML form that would take the value of the textbox and create a URL.
Here is my form:
<form id="searchForm" method="GET" action="http://searchserver/results.aspx target="_blank">
<input type="text" name="p" size="18" maxlength="256" value="hello world"/>
</form>
As you can see, when hitting enter, it sends the value to the new browser with the url as: "http://searchserver/results.aspx?p=hello+world"
Is there a way to force the plus (+) sign here into the %20 character? So it would be: "http://searchserver/results.aspx?p=hello*%20*world"
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是在没有任何框架的情况下如何做到这一点:
享受。
This is how you'd do it without any framework:
Enjoy.