mailto用法
如何使用mailto?
1)基本用法
mailto后跟的是收信人。
可使用参数列表
参数传递方式同页面之间传递值一样,可以使用查询字符串,也可以用form
querystring方式:
2)示例说明
1)基本用法
<a href=mailto:sample@163.com>send email</a>
或者<form action="mailto:sample@163.com">
</form>
</form>
mailto后跟的是收信人。
可使用参数列表
to | 收信人 |
suject | 主题 |
cc | 抄送 |
bcc | 暗抄送 |
body | 内容 |
querystring方式:
<a href="mailto:sample@163.com?subject=test&cc=sample@hotmail.com&body=use mailto sample">send mail</a>
form方式<form name='sendmail' action='mailto:sample@163.com'>
<input name='cc' type='text' value='sample@hotmail.com'>
<input name='subject' type='text' value='test'>
<input name='body' type='text' value='use mailto sample'>
</form>
两种方式同样传递所有参数。<input name='cc' type='text' value='sample@hotmail.com'>
<input name='subject' type='text' value='test'>
<input name='body' type='text' value='use mailto sample'>
</form>
2)示例说明
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Send Email </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
Date.prototype.toString=function()
{
var d = new Date();
var ret = d.getYear();
var m = d.getMonth()+1;
ret+=m.length>1?m:'0'+m;
var date= d.getDate();
ret+=date.length>1?date:'0'+date;
return ret;
}
var initSubject='test'+new Date().toString(),initTo='sample@163.com',initCC='sample@hotmail.com',initBody='use mailto sample';
function submitHandler()
{
var subject = subText.value;
var to = toText.value;
var cc = ccText.value;
var body = bodyText.value;
mailTo.href="mailto:"+to+"?cc="+cc+"&subject="+subject+"&body="+body;
mailTo.click();
}
function init()
{
subText.value=initSubject;
toText.value=initTo;
ccText.value=initCC;
bodyText.value=initBody;
}
</script>
<style>
.label{font-weight:bold;postion:absolute;width:80px;}
.head{font-color:black;font-weight:bold;}
.bd{float:left;width:77px;font-weight:bold;}
</style>
<BODY onload="init()">
<div class="head">Use mailto Send Email</div>
<div>
<span class="label">Subject:</span><input id="subText" type="text" size=50 value="TM V14.2 Bug Fix Questions_20080221">
</div>
<div>
<span class="label">To:</span><input id="toText" type="text" size=50 value="">
</div>
<div>
<span class="label">CC:</span><input id="ccText" type="text" size=50 value="">
</div>
<div>
<span class="bd">Body:</span><textarea id="bodyText" rows=20 cols=100></textarea>
</div>
<input name="btSend" type="button" value="send email" onclick="submitHandler();">
<a href="mailto:" id="mailTo"></a>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> Send Email </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
Date.prototype.toString=function()
{
var d = new Date();
var ret = d.getYear();
var m = d.getMonth()+1;
ret+=m.length>1?m:'0'+m;
var date= d.getDate();
ret+=date.length>1?date:'0'+date;
return ret;
}
var initSubject='test'+new Date().toString(),initTo='sample@163.com',initCC='sample@hotmail.com',initBody='use mailto sample';
function submitHandler()
{
var subject = subText.value;
var to = toText.value;
var cc = ccText.value;
var body = bodyText.value;
mailTo.href="mailto:"+to+"?cc="+cc+"&subject="+subject+"&body="+body;
mailTo.click();
}
function init()
{
subText.value=initSubject;
toText.value=initTo;
ccText.value=initCC;
bodyText.value=initBody;
}
</script>
<style>
.label{font-weight:bold;postion:absolute;width:80px;}
.head{font-color:black;font-weight:bold;}
.bd{float:left;width:77px;font-weight:bold;}
</style>
<BODY onload="init()">
<div class="head">Use mailto Send Email</div>
<div>
<span class="label">Subject:</span><input id="subText" type="text" size=50 value="TM V14.2 Bug Fix Questions_20080221">
</div>
<div>
<span class="label">To:</span><input id="toText" type="text" size=50 value="">
</div>
<div>
<span class="label">CC:</span><input id="ccText" type="text" size=50 value="">
</div>
<div>
<span class="bd">Body:</span><textarea id="bodyText" rows=20 cols=100></textarea>
</div>
<input name="btSend" type="button" value="send email" onclick="submitHandler();">
<a href="mailto:" id="mailTo"></a>
</BODY>
</HTML>
成功者找方法,失败者找借口!