Spaces converting to '+' from HTML form

£可爱£侵袭症+ 提交于 2020-01-14 13:07:13

问题


So I've been playing around with HTML forms and I am kind of new you all of this so any help would go a long way! But anyway... This is my form coding for emailing.

So when I submit that form with the correct areas filled, it then opens in Outlook (2010 If that matters) were it then converts the spaces in the body of the email into '+' (Plus symbols)... Can anyone give me ideas? This HTML will be used on an offline site within our network and will not go live. All computers are on the domain and will have access to this HTML link on there desktop.


回答1:


You should set the enctype attribute of the <form> tag to text.

<form enctype="text/plain" ...

More details in this KB

In both cases, the FORM data is e-mailed in as an Attachment, in an encoded format. For instance, in the preceding case, this is how the data looks:

Subject=Test+Subject&Body=%09kfdskfdksfkds%0D%0A%09

This is because the default ENCTYPE attribute for the FORM element is "application/x-www-form-urlencoded". To e-mail data in > plain-text format instead, explicitly specify an ENCTYPE attribute of "text/plain". For instance:

<FORM Action="mailto:xyz" METHOD="POST" ENCTYPE="text/plain">
    mailto: protocol test:
    <Br>Subject: 
    <INPUT name="Subject" value="Test Subject">
    <Br>Body:&#xa0;
    <TEXTAREA name="Body">
    kfdskfdksfkds
    </TEXTAREA>
    <BR>
    <INPUT type="submit" value="Submit"> 
</FORM>

produces the following Body:

Subject=Test Subject
Body=   kfdskfdksfkds



回答2:


You can use %20 for spaces in mailto links. I think you need to convert the + to spaces before you open the mailto link.



来源:https://stackoverflow.com/questions/20857390/spaces-converting-to-from-html-form

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