从DOM获取非英语字符串(标题)并用javascript将其传递给电子邮件
我有一个简单的书签,可以通过邮件发送链接:从DOM获取非英语字符串(标题)并用javascript将其传递给电子邮件,javascript,string,dom,encoding,Javascript,String,Dom,Encoding,我有一个简单的书签,可以通过邮件发送链接: javascript:location.href='mailto:?SUBJECT='+document.title +'&BODY='+escape(location.href); 问题是它不处理非英语标题。例如,下一页的-e-mail主题将包含垃圾 <html> <head> <title>Заголовок</title> </head> <body> The
javascript:location.href='mailto:?SUBJECT='+document.title +'&BODY='+escape(location.href);
问题是它不处理非英语标题。例如,下一页的-e-mail主题将包含垃圾
<html>
<head>
<title>Заголовок</title>
</head>
<body>
The title of the document is:
<script type="text/javascript">
document.write( document.title);
</script>
</body>
</html>
Заголовок
该文件的标题为:
文件。书写(文件。标题);
我应该做哪些更改才能使其与其他语言/编码一起工作?
javascript:location.href='mailto:?SUBJECT='+encodeURIComponent(document.title)+'&BODY='+encodeURIComponent(location.href)代码>我们也遇到了这个问题。恐怕没有一种通用的解决方案适用于所有电子邮件客户端,比如旧版本的Outlook。你可能是对的,因为下面两个答案都不能解决问题(至少Outlook 2003不能)。您找到Outlook 2003的解决方案了吗?“encodeURIComponent”解决方案是否适用于较新版本的Outlook?
javascript:location.href='mailto:?SUBJECT='+encodeURIComponent(document.title)+'&BODY='+encodeURIComponent(location.href)