HTML标记属性值中的换行符

时间:2022-11-26 23:20:43

How can I insert line breaks inside HTML attribute values, like this:

如何在HTML属性值中插入换行符,如下所示:

<href="mailto:info@example.com?subject=TestMail&body=Please enter the following details.
Name
Email
Mob No">

When the user replies, the body part should display as below:

当用户回复时,正文部分应显示如下:

Please enter the following details.
1. Name
2. Email
3. Mob No

I tried using <br> tags, but they get displayed.

我尝试使用
标签,但它们会显示出来。

1 个解决方案

#1


29  

The line break should be URL encoded into %0D%0A

换行符应该URL编码为%0D%0A

Your mailto will look like:

您的mailto将如下所示:

    <a href="mailto:xxx@example.com?subject&body=1.Name%0D%0A2.Email">mailme</a>

Info from http://www.cubetoon.com/2008/how-to-enter-line-break-into-mailto-body-command/

来自http://www.cubetoon.com/2008/how-to-enter-line-break-into-mailto-body-command/的信息

#1


29  

The line break should be URL encoded into %0D%0A

换行符应该URL编码为%0D%0A

Your mailto will look like:

您的mailto将如下所示:

    <a href="mailto:xxx@example.com?subject&body=1.Name%0D%0A2.Email">mailme</a>

Info from http://www.cubetoon.com/2008/how-to-enter-line-break-into-mailto-body-command/

来自http://www.cubetoon.com/2008/how-to-enter-line-break-into-mailto-body-command/的信息