RT,代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
</head>
<script type="text/javascript">
function toOutLook(){
var objFrm = document.frmEmail;
var msg = "";
msg += "Name: " + objFrm.name.value + "%0A%0C";
msg += "Email: " + objFrm.email.value + "%0A%0C";
objFrm.action = "mailto:kimey@tallyfarm.com?subject=TallyHoFarm Contact Form&body=" + msg;
objFrm.method = "post";
// msg += "Name: " + objFrm.name.value + "\n";
// msg += "Email: " + objFrm.email.value + "\n";
// objFrm.subject.value = "TallyHoFarm Contact Form2";
// objFrm.body.value = msg;
// objFrm.action = "mailto:kimey@tallyfarm.com";
// objFrm.method = "get";
objFrm.submit();
window.location.reload();
}
</script>
<body>
<form name="frmEmail" action="">
<input type="hidden" name="subject" />
<input type="hidden" name="body" />
<div>
Name</div>
<div>
<input name="name" type="text" /></div>
<br />
<br />
<div>
Email</div>
<div>
<input name="email" type="text" /></div>
<br />
<br />
<div>
<input type="button" name="" value="Submit" onclick="toOutLook();" />
</div>
</form>
</body>
</html>
1. 现在用POST方式发送,在本地测试,新建邮件里面的subject和body都正常显示,“%0A%0C”也可以显示成换行;但是在别人机器上测试的时候,subject和body正常显示,但“%0A%0C”却不能显示成换行,同时还带有个附件“PostData.att”! ,请问为什么?
2. 如果换成注释行的Get方法,新建邮件里面的subject和body都正常显示,但是空格都变成了加号“+”,如果用escape()方法编码,subject和body正常显示,但是空格,冒号都被编码成“%0A%0C”等等,请问邮件里面怎么去解码啊?
谢谢!~~
试试 encodeURI(XX) 这个吧, XX 为要发送的字符串
用這個
encodeURIComponent
主要是编码的问题