编码要发送到Web服务器的查询字符串时 - 何时使用escape()以及何时使用encodeURI()或encodeURIComponent():
使用转义:
escape("% +&=");
Run Code Online (Sandbox Code Playgroud)
要么
使用encodeURI()/ encodeURIComponent()
encodeURI("http://www.google.com?var1=value1&var2=value2");
encodeURIComponent("var1=value1&var2=value2");
Run Code Online (Sandbox Code Playgroud) 我想在我的mailto正文中插入换行符.我尝试了%0A,%0D和%0D%0A.没有什么对我有用.我在Mac OSX上使用Google Chrome在Gmail,Yahoo,Apple Mail,Outlook 2010,Outlook.com和Thunderbird上进行了测试.
有什么帮助吗?
这是我的代码:
<a href="mailto:email@mycompany.com?subject=Subscribe&body=Lastame%20%3A%0D%0A%20Firstname%20%3A"><img alt="Subscribe" class="center" height="50" src="subscribe.png" style="width: 137px; height: 50px; color: #4da6f7; font-size: 20px; display: block;" width="137"></a>
Run Code Online (Sandbox Code Playgroud) 在JavaScript中:
encodeURIComponent("©?") == "%C2%A9%E2%88%9A"
Run Code Online (Sandbox Code Playgroud)
是否有C#应用程序的等价物?对于我使用的转义HTML字符:
txtOut.Text = Regex.Replace(txtIn.Text, @"[\u0080-\uFFFF]",
m => @"&#" + ((int)m.Value[0]).ToString() + ";");
Run Code Online (Sandbox Code Playgroud)
但我不确定如何将匹配转换为JS使用的正确十六进制格式.例如这段代码:
txtOut.Text = Regex.Replace(txtIn.Text, @"[\u0080-\uFFFF]",
m => @"%" + String.Format("{0:x}", ((int)m.Value[0])));
Run Code Online (Sandbox Code Playgroud)
返回" %a9%221a"for "©?"而不是"%C2%A9%E2%88%9A".看起来我需要将字符串拆分为字节或其他东西.
编辑:这是一个Windows应用程序中,唯一可用的项目System.Web有:AspNetHostingPermission,AspNetHostingPermissionAttribute,和AspNetHostingPermissionLevel.
可能重复:
mailto链接多个正文行
只是一个简单的问题.我正在为慈善机构创建一个网站,他们在网站上有一个部分,人们可以就如何为他们的事业筹集更多资金提出一些建议.他们的网站只是简单的HTML,JS和CSS,以保持轻量级.我添加了一个mailto:允许人们向他们发送电子邮件,但他们想要更多信息,如他们的姓名和联系方式.我想知道是否有一种方法来格式化正文,以便有新的行:
name:
email:
tel:
postal address:
Run Code Online (Sandbox Code Playgroud)
谢谢!
这就是我mailto现在的样子.欢迎任何帮助或建议:
<a href="mailto:someone@example.com?subject=Suggestions&body=Your%20suggestions%20are%20really%20important%20to%20us%20,thanks!">Send suggestions!</a>
Run Code Online (Sandbox Code Playgroud) 我已经用于%0D%0A换行。它适用于许多电子邮件客户端,但它不会在雅虎电子邮件中换行。为什么?有没有其他方法可以做到这一点?
我想了解为什么反应会这样。
这有效
class Feed extends React.Component {
constructor(props) {
super(props);
}
render() {
const posts = [{ id: 1, title: 'post-1' }, { id: 2, title: 'post-2' }];
return (
<>
{posts.map(post => (
<Post key={post.id} title={post.title} />
))}
</>
Run Code Online (Sandbox Code Playgroud)
但这并不
class Feed extends React.Component {
constructor(props) {
super(props);
}
render() {
const posts = [{ id: 1, title: 'post-1' }, { id: 2, title: 'post-2' }];
return (
<>
{posts.map(post => {
// changes are here
if (post.id < …Run Code Online (Sandbox Code Playgroud) 出于某种原因\n在javascript中不适合我.无论如何要修复它或使用HTML?在我的情况下,我认为使用<br>将无法在我的href中工作.你有什么建议.
在这里工作JSFiddle .
HTML:
<a id = 'emailoff' href = "" target = "_blank">
<div id= "btn1">
<h2 id = "enter">Send Email</h2>
</div>
</a>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
$('#btn1').click(function() {
$("#emailoff").attr("href", "mailto:" +
"?subject=Your ThinOptics glasses" +
"&body=To get your new ThinOptics glasses simply click this link and pick the case and color you like best. You'll get free shipping on your order. \n"+
" WWw.Thinoptics.Com/teddy@shalon.com \n" +
"\n Enjoy")
});
Run Code Online (Sandbox Code Playgroud) html ×3
javascript ×3
mailto ×3
email ×2
encoding ×2
.net ×1
c# ×1
jquery ×1
query-string ×1
reactjs ×1
windows ×1
yahoo-mail ×1