Html 如何在mailto的正文中传递URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4710349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to pass an URL in mailto's body
提问by oditiwebs.com
I need to send an URL of my site in the body so the mail recipient can click on that to join my site.
我需要在正文中发送我网站的 URL,以便邮件收件人可以点击它加入我的网站。
However currently mail client renders the mail like this:
但是目前邮件客户端呈现的邮件是这样的:
Link goes here http://www.example.com/foo.php?this=a
The URL is truncated on the &
symbol, thus the whole process of joining failed. How can I pass the URL like http://www.example.com/foo.php?this=a&join=abc&user454in mailto body?
URL在&
符号上被截断,因此整个加入过程失败。如何在mailto正文中传递像http://www.example.com/foo.php?this=a&join=abc&user454这样的URL ?
My current HTML is the following:
我当前的 HTML 如下:
<a href="mailto:[email protected]?body=Link goes here http://www.example.com/foo.php?this=a&really=long&url=with&lots=and&lots=and&lots=of&prameters=on_it
">Link text goes here</a>
回答by Matt V.
You need to encode the URL. This URL Decoder/Encoder toolwill do the trick. The following seems to work:
您需要对 URL 进行编码。这个URL 解码器/编码器工具可以解决问题。以下似乎有效:
<a href="mailto:[email protected]?body=Link goes here http%3A%2F%2Fwww.example.com%2Ffoo.php%3Fthis%3Da%26join%3Dabc%26user454
">Link text goes here</a>
回答by tekknolagi
I would URL encode the link you are using, so it would be:
我会对您正在使用的链接进行 URL 编码,因此它将是:
<a href="mailto:[email protected]?body=Link%20goes%20here%20http%3A%2F%2Fwww.example.com%2Ffoo.php%3Fthis%3Da%26join%3Dabc%26user454">Link text goes here</a>
回答by BZ1
You can type javascript:alert(escape("YOUR URL")); in the address box of a browser and get the URL made safe for a mailto link. For example, type the following inside the address box of a browser and press Enter.
你可以输入 javascript:alert(escape("YOUR URL")); 在浏览器的地址框中,获取对 mailto 链接安全的 URL。例如,在浏览器的地址框中键入以下内容,然后按 Enter。
javascript:alert(escape("http://www.example.com/foo.php?this=a"));
You will get a message box that will display.
您将看到一个将显示的消息框。
http%3A//www.example.com/foo.php%3Fthis%3Da
Opera and Mozilla-based browsers allow you to copy the displayed content from the alert box.
基于 Opera 和 Mozilla 的浏览器允许您从警报框中复制显示的内容。
You could improve it by typing
你可以通过输入来改进它
javascript:alert("mailto:[email protected]?subject=My Subject&body="+escape("http://www.example.com/foo.php?this=a"));
so that you get the subject and body included in the link. Other improvements could be using a From name and line breaks using %0a.
以便您获得链接中包含的主题和正文。其他改进可能是使用 From 名称和使用 %0a 的换行符。
javascript:alert("mailto:Just Me <[email protected]>?subject=My Subject&body=This is the link:%250a"+escape("http://www.example.com/foo.php?this=a"));
回答by khaled_webdev
as I see you are using php then you can use "urlencode()" function
如我所见,您正在使用 php,那么您可以使用“urlencode()”函数
<a href="mailto:[email protected]?body=Link goes here <?php echo urlencode('http://www.example.com/foo.php?this=a&really=long&url=with&lots=and&lots=and&lots=of&prameters=on_it
');?>">Link text goes here</a>