mailto: problem

[亡魂溺海] 提交于 2020-01-06 08:22:30

问题


I'm trying to set up the following mailto: link:

<a href='mailto:info@example.com?subject=Testing&body=http://www.google.com?foo=1&bar=2'>Send mail</a>

However the second argument (bar) is cut off because it is seen as an argument of the mailto link and not the link I'm putting in the body. I tried &amp; but it does the same thing since it's being rendered into the link.


回答1:


What about something like this :

<a href='mailto:info@example.com?subject=Testing&amp;body=http%3A%2F%2Fwww.google.com%3Ffoo%3D1%26bar%3D2'>Send mail</a>

ie, urlencoding the whole body field, to make sure nothing causes any problem ?




回答2:


Use "%26" instead or use urluncoding like suggested in another answer. For PHP rawurlencode works well.

<a href='mailto:info@example.com?subject=Testing&body=http://www.google.com?foo=1%26bar=2'>Send mail</a>



回答3:


Try putting the value for body into quotes like:

'mailto:info@example.com?subject=Testing&body="http://www.google.com?foo=1&bar=2"'

Nvm, turns out putting %26 works instead of ampersand.




回答4:


Use %26 as &.. its the html escape code for &.

<a href='mailto:info@example.com?subject=Testing&body=http://www.google.com?foo=1%26bar=2'>Send mail</a>



来源:https://stackoverflow.com/questions/1455867/mailto-problem

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