13

我正在编辑一个 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>
4

1 回答 1

35

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

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

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

于 2013-08-01T14:23:17.723 回答