HTML 邮寄表单 : prefill subject and body

标签 html contact-form

我正在编辑 HTML 模板,需要联系表单部分的帮助。我想做到这一点,当用户点击发送消息按钮时,默认的电子邮件客户端(在我的例子中是 Outlook)打开,电子邮件的名称、主题和正文都预先填充了表单中的值。我该怎么做?

联系表单标记:

<div id="footer" class="container">
    <header>
        <h2>Questions or comments? <strong>Get in touch:</strong></h2>
    </header>
    <div class="row">
        <div class="6u">
            <section>
                <form>
                    <div class="row half">
                        <div class="6u">
                            <input name="name" placeholder="Name" type="text" class="text" />
                        </div>
                        <div class="6u">
                            <input name="Subject" placeholder="Subject" type="text" class="text" />
                        </div>
                    </div>
                    <div class="row half">
                        <div class="12u">
                            <textarea name="message" placeholder="Message"></textarea>
                        </div>
                    </div>
                    <div class="row half">
                        <div class="12u">
                            <a href="#" class="button button-icon icon icon-envelope">Send Message</a>
                        </div>
                    </div>
                </form>
            </section>
        </div>

        <div class="row">
            <ul class="icons 6u">
                <li class="icon icon-home">
                    <h6> 1235 street <br />
                    city, state 0000<br /> </h6>
                </li>
                <li class="icon icon-phone">
                    <h6>(000) 000-0000 </h6>
                </li>
                <li class="icon icon-envelope">
                    <a href="mailto:hello@hello.com">hello@hello.com</a>
                </li>
            </ul>
        </div>
    </div>
</div>

最佳答案

如果我没理解错的话,您可以使用 mailto 链接在电子邮件客户端中打开时预定义消息的正文和电子邮件。

<a href="mailto:hello@hello.com?subject=Email Subject&body=Contents of email">hello@hello.com</a>

AJAX 表单可能更合适,因为用户不需要电子邮件客户端来打开链接。

关于HTML 邮寄表单 : prefill subject and body,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17996602/

相关文章:

Jquery 在点击时改进 .css() 动画

html - 无法将输入字段保留在联系表单的 div 内

javascript - 使用 Javascript 的联系表

php - 将主题添加到 SENDMAIL.PHP 文件

javascript - 联系表上的帮助不大?

html - 取id时如何套用css样式?

html - 阻止背景图像落后于页眉/页脚

php - Phonegap 联系表单无法通过 PHP 运行

javascript - 如何从 div 复制所有内容 (<p><strong>) 并粘贴到模式中

javascript - Jquery 从 div 部分追加文本