轉載: http://www.haorooms.com/post/mailto_link_html
什么是mailto鏈接?
mailto鏈接是一種html鏈接,能夠設置你電腦中郵件的默認發送信息。但是需要你電腦中安裝默認的E-mail軟件,類似Microsoft Outlook等等。加入您已經安裝了Microsoft Outlook,那么直接點擊mailto鏈接就可以獲得默認設置的郵件信息。
怎樣在html中創建mailto 鏈接?
mailto 鏈接一般是寫在herf當中的,相信很多朋友之前都用過!
<a href="mailto:name@email.com">Email</a>
參數如下:
參數 | 描述 |
---|---|
mailto:name@email.com | e-mail recipient address |
cc=name@email.com | carbon copy e-mail address |
bcc=name@email.com | blind carbon copy e-mail address |
subject=subject text | e-mail的題目 |
body=body text | e-mail的內容 |
? | 和瀏覽器地址操作一樣,第一個參數符合是? |
& | 其他參數符號是& |
mailto例子
僅僅填寫發送郵件的地址!
<a href="mailto:haorooms@126.com">給haorooms發送郵件</a>
是如下這樣的鏈接:
有郵件地址和郵件主題的鏈接
<a href="mailto:haorooms@126.com?subject=The%20subject%20of%20the%20mail">給haorooms發送郵件</a>
%20 是瀏覽器對於空格的編碼,建議看我之前寫的一篇文章url的三個js編碼函數escape(),encodeURI(),encodeURIComponent()簡介
測試如下:
各個參數都有的郵件,代碼如下:
<a href="mailto:haorooms@126.com?cc=name2@rapidtables.com&bcc=name3@rapidtables.com &subject=The%20subject%20of%20the%20email &body=The%20body%20of%20the%20email"> 發送Email 用cc, bcc, 主題和內容</a>
測試如下:
mailto題目和內容中如何增加空格
%20是空格的意思,我之前的文章寫過,是瀏覽器的編碼,具體可以看http://www.haorooms.com/post/js_escape_encodeURIComponent
在這里就不翻譯了。