admin管理员组文章数量:1418685
My code:
<a href="mailto:[email protected]?subject=This%20is%20Subject&body=Hello%0D%0A%0D%0Aworld..">
click here to mail me
</a>
Expected output:
What i am getting as output now:
I tried using %0D%0A
but it doesn't work. Also i tried few java script methods from here But those don't seems to work.
The app i used to check mailto: output is default Gmail App from my android device.
EDIT [SOLUTION]
Just using <br>
tag works fine with third party applications like gmail for android.
My code:
<a href="mailto:[email protected]?subject=This%20is%20Subject&body=Hello%0D%0A%0D%0Aworld..">
click here to mail me
</a>
Expected output:
What i am getting as output now:
I tried using %0D%0A
but it doesn't work. Also i tried few java script methods from here But those don't seems to work.
The app i used to check mailto: output is default Gmail App from my android device.
EDIT [SOLUTION]
Just using <br>
tag works fine with third party applications like gmail for android.
3 Answers
Reset to default 4Update 09 Sep 2020
This has been changed again in a recent Gmail release - e.g. version 2020.08.09.327326543.Release
- \r\n
for line breaks when using mailto:
now works again and <br>
does not.
I can only assume it was a regression bug rather than an intentional change in the Gmail app which has now been fixed.
Original answer:
I've seen an issue arise recently in my Android apps which have been using encoded \r\n
for line breaks when using mailto:
to open Gmail as the default email client.
While this previously worked fine, now the line break is appearing as a space.
Upon doing some testing, it appears that the behaviour of the Gmail app has changed in a recent update.
I created a test page which contains two links, one using encoded \r\n
and one using <br>
for a line break in the body:
mailto:[email protected]?body=Hello%0D%0Aworld
mailto:[email protected]?body=Hello<br>world
In an Android Emulator running Android 10/API 29 with Gmail app version of 2019.05.12.250526289.release
:
The \r\n
link works correctly:
But the <br>
link does not:
In an Android Emulator running Android 11 Beta/API 30 with Gmail app version of 2020.04.29.309137422.release
:
The <br>
link works correctly:
But the \r\n
link does not:
%0D%0A are the carry return and line feed characters, use %20 for space as you do in the subject:
<a href="mailto:[email protected]?subject=This%20is%20Subject&body=Hello%20world..">
click here to mail me
</a>
And if you want a line break use %0D%0A
as in:
<a href="mailto:[email protected]?subject=This%20is%20Subject&body=Hello%0D%0Aworld..">
click here to mail me
</a>
You can check what this values mean in a ascii table if you check the hexadecimal value you see what A, D, E and 20 are equal to.
Just using <br>
tag, works fine with third party applications like gmail for android.
Fixed code,
<a href="mailto:[email protected]?subject=This%20is%20Subject&body=Hello<br><br>world..">
click here to mail me
</a>
本文标签: javascriptHow to fix not showing line break in body while using mailtoStack Overflow
版权声明:本文标题:javascript - How to fix not showing line break in body while using mailto? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745291861a2651842.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论