Set a mailto link with a subject containing an ampersand (&)

亡梦爱人 提交于 2019-11-30 00:21:17

问题


Im using the following mailto link to send an email:

 <a class="share3" title="" href="mailto:?subject=@check&amp;body=@domain">

It works well, but sometimes my subject will contain an ampersand (&) character, and when it does my email is created without a body.

Any way to resolve this problem?


回答1:


In order to get special/reserved characters into a URL, you must encode them - to get an & to work, it must be encoded to %26.

More details here: http://www.w3schools.com/tags/ref_urlencode.asp




回答2:


use %26 for the & in the subject.



来源:https://stackoverflow.com/questions/23682010/set-a-mailto-link-with-a-subject-containing-an-ampersand

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