我正在嘗試使用以下內容從 html 頁面發送郵件:
<script>
function sendMail() {
var link = "mailto:[email protected] &subject=" encodeURIComponent(document.getElementById('myText').value)
"&body=" encodeURIComponent(document.getElementById('myText2').value)
;
window.location.href = link;
}
</script>
<!-- Contact Form -->
<div class="col-md-6 contact">
<form role="form">
<!-- Name -->
<div class="row">
<div class="col-md-6">
<!-- E-Mail -->
<div class="form-group">
<input type="text" class="form-control" placeholder="Your name" id="myText">
</div>
</div>
<div class="col-md-6">
<!-- Phone Number -->
<div class="form-group">
<input type="email" class="form-control" placeholder="Email address">
</div>
</div>
</div>
<!-- Message Area -->
<div class="form-group">
<textarea class="form-control" placeholder="Write you message here..." style="height:232px;" id="myText2"></textarea>
</div>
<!-- Subtmit Button -->
<button type="submit" class="btn btn-send" onclick="sendMail(); return false">
Send message
</button>
</form>
</div>
當我按下按鈕單擊所有資料時,所有資料都會出現在默認郵件應用程式“收件人:”文本輸入區域中。誰能告訴我如何正確拆分主體和主體?我希望這些默認情況下進入電子郵件的主題和正文部分。
uj5u.com熱心網友回復:
您的查詢字串變數應該以“?”開頭,而不是“&”。
var link = "mailto:[email protected]?subject=" encodeURIComponent(document.getElementById('myText').value)
"&body=" encodeURIComponent(document.getElementById('myText2').value)
;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/383122.html
標籤:javascript html 形式 电子邮件
