我正在尝试使用此 JS 在客户端计算机上打开一封新电子邮件,其中页面标题已填充在主题行和正文中,由此链接调用<a href="javascript:mailpage()">Email</a>
function mailpage()
{ mail_str = "mailto:?subject= " + document.title; mail_str +=
"&body=Hi, I thought you might be interested in this: "
+ document.title; mail_str +=
". You can check out the web site at "
+ location.href; location.href = mail_str;
}
但是我的一些页面在页面标题中有一个 & 作为页面标题的一部分,并且该功能会阻塞,并且只在 & 之前插入文本,而不是 & 或之后的任何内容。(是的,“扼流圈”是一个技术性很强的术语。)
有没有办法逃避 & 让 JS 不会窒息?& 实际上出现@
在页面源中。还是我需要去一个 php 函数?谢谢。
编辑:这有效: + encodeURIComponent(document.title); mail_str +=