我正在处理HTML表单,它将通过我的页面上的电子邮件客户端发送电子邮件。
问题是当我按下发送按钮时,它会打开我的默认电子邮件客户端,但它也会导入所有标签。有没有办法避免导入标签?
正如您在附加的屏幕截图中看到的:
这也是我一直在使用的HTML代码:
<body>
<div id="wrapper">
<table>
<tr>
<td class="banner"><img src="images/test_500.png" width="499" height="161" alt="test"></td>
</tr>
<tr>
<td id="content"><!-- p class="font155"> TEST PAGE</p -->
<p>CONTACT US</p>
<div id="form-div">
<form method="post" action="mailto:john@doe.com?subject=Email subscription for test" enctype="text/plain">
<label>Subject</label><br />
<input type="text" name="Subject" value="" size="40" />
<br />
<br />
<label for="name">Name</label><br />
<input type="text" name="Name" size="40">
<br />
<br />
<label for="email">E-mail</label><br />
<input type="email" name="Email" size="40">
<br />
<br />
<label for="comment">Comment</label><br />
<textarea name="Comment" rows="5" cols="40"></textarea>
<br />
<br />
<input type="submit" value="Send">
<!-- input type="reset" value="Reset" -->
</form>
</div>
</td>
</tr>
<tr>
<td><!-- hr / --></td>
</tr>
</table>
</div>
<!-- End Save for Web Slices -->
</body>
答案 0 :(得分:1)
你可以使用JS(在我的例子中也是jQuery lib)来做,只需添加以下代码:
$(function() {
$('form').submit(function(e) {
e.preventDefault();
var action = $(this).attr('action');
var msg = '';
$(this).find('input, textarea').not('[type=submit]').each(function(i, el) {
msg += el.value; //here you can add break line(%0D%0A) or delimeter
});
if (msg) {
var link = action + '&body=' + msg;
location.href = action + '&body=' + msg;
//window.open(link, '_blank'); //if you need open new window
}
});
});