[英]How to prevent form fields ending up in the message body when using HTML mailto?
我正在使用mailto:
並且想知道為什么我用來收集要放入電子郵件客戶端字段中的數據的表單也最終落入消息主體中,如下所示:
hello // test body
msg_address=hello@some.com
msg_comment=hello
msg_cc_message=on
我的表單action
屬性設置如下:
var form = $(this).closest('form'),
first = "info",
last = "some.com"
mailto = "mailto:"+first+"@"+last+"?",
subject = "subject=Website enquiry&",
message = "body="+$('#msg_comment').val(),
bcc = $('#msg_cc').is(':checked') ? "bcc=" + form.find('#msg_address').val() + "&" : "";
form.attr("action",mailto+bcc+subject+message).submit()
我希望郵件正文僅包含message
設置的內容,而不包含整個表單內容(包括表單字段名稱)。
問題 :
有什么方法可以防止表單域顯示在郵件正文中?
編輯:
這是我的表格:
<form action="" method="post" enctype="text/plain" name="mailer">
<label for="msg_address" data-i18n="contact.label_email" class="t">Email:</label>
<input data-role="text" type="text" id="msg_address" name="msg_address" value="" maxlength="100" />
<label for="msg_comment" data-i18n="contact.label_message" class="t">Your Message:</label>
<textarea rows="10" cols="20" id="msg_comment" name="msg_comment"></textarea><br />
<input type="checkbox" name="msg_cc" id="msg_cc" class="t" data-i18n-target="" data-i18n="" />
<label for="msg_cc" data-i18n="contact.label_cc" data-i18n-target=".ui-btn-text" class="t">CC to Email address provided</label>
<div data-role="controlgroup" data-type="horizontal" class="mailer_menu">
<input type="reset" value="Reset" data-i18n="contact.delete" data-i18n-target="" class="t" />
<input type="button" id="mail_trigger" value="Send" data-i18n="contact.send" class="t" data-iconpos="right" data-i18n-target="" data-theme="b" data-icon="arrow-r" />
</div>
</form>
提交表單時,根據定義,它將把類似輸入的元素(輸入,文本區域等)發送到指定的目標。
現在,在javascript中,您可以更改action屬性以創建格式更精美的電子郵件模板,但是表單中仍然包含所有輸入,因此根據定義它們將被添加到正文中。
為防止這種情況,您可以將隱藏表單放入html中,其中不包含類似輸入的元素,甚至可以將其作為自封閉元素,然后修改操作並提交該表單。 甚至可以即時創建一個。
這樣,您將不需要的電子郵件中沒有任何內容。 請注意取消第一個表單的提交。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.