如何在提交表单数据后防止 google 应用程序脚本 reloading/redirecting 我的网页..?
How to prevent google app script reloading/redirecting my webpage after form data submission ..?
我正在使用 google 应用程序脚本将表单数据提交到我的电子邮件。这是一个网页联系表格。但默认情况下,在点击提交按钮后,它会转到不同的页面并显示“result:success”奇怪的信息。我想防止重新加载或重定向。我该怎么做?
HTML
<form id="email-form" class="gform" action="https://script.google.com/macros/s/AKfyJu890G2t-RuhJxTNIA/exec" method="post">
<div class="email-name">
<input id="name" name="name" type="text" class="form-control" placeholder="write name" autocomplete="off">
</div>
<div class="email-main">
<input id="email" name="email" type="text" class="form-control" placeholder="write email" autocomplete="off">
</div>
<div class="email-subject">
<input id="subject" name="subject" type="text" class="form-control" placeholder="write related sub" autocomplete="off">
</div>
<div class="email-message">
<textarea id="message" name="message" class="form-control" placeholder="write message here"></textarea>
</div>
<button id="send-email" type="submit">SUBMIT EMAIL</button>
</form>
我可以使用 onclick 事件添加警报,但仍然会重新加载。请提供 javascript 代码以防止此表单的默认行为。
之前我已经通过将提交按钮移出表单来解决这个问题。
<form id="email-form" class="gform" action="https://script.google.com/macros/s/AKfyJu890G2t-RuhJxTNIA/exec" method="post">
<div class="email-name">
<input id="name" name="name" type="text" class="form-control" placeholder="write name" autocomplete="off">
</div>
<div class="email-main">
<input id="email" name="email" type="text" class="form-control" placeholder="write email" autocomplete="off">
</div>
<div class="email-subject">
<input id="subject" name="subject" type="text" class="form-control" placeholder="write related sub" autocomplete="off">
</div>
<div class="email-message">
<textarea id="message" name="message" class="form-control" placeholder="write message here"></textarea>
</div>
</form>
<button id="send-email" type="submit">SUBMIT EMAIL</button>
如果这不起作用,您可以尝试将 target
用于隐藏的 iframe。
我正在使用 google 应用程序脚本将表单数据提交到我的电子邮件。这是一个网页联系表格。但默认情况下,在点击提交按钮后,它会转到不同的页面并显示“result:success”奇怪的信息。我想防止重新加载或重定向。我该怎么做?
HTML
<form id="email-form" class="gform" action="https://script.google.com/macros/s/AKfyJu890G2t-RuhJxTNIA/exec" method="post">
<div class="email-name">
<input id="name" name="name" type="text" class="form-control" placeholder="write name" autocomplete="off">
</div>
<div class="email-main">
<input id="email" name="email" type="text" class="form-control" placeholder="write email" autocomplete="off">
</div>
<div class="email-subject">
<input id="subject" name="subject" type="text" class="form-control" placeholder="write related sub" autocomplete="off">
</div>
<div class="email-message">
<textarea id="message" name="message" class="form-control" placeholder="write message here"></textarea>
</div>
<button id="send-email" type="submit">SUBMIT EMAIL</button>
</form>
我可以使用 onclick 事件添加警报,但仍然会重新加载。请提供 javascript 代码以防止此表单的默认行为。
之前我已经通过将提交按钮移出表单来解决这个问题。
<form id="email-form" class="gform" action="https://script.google.com/macros/s/AKfyJu890G2t-RuhJxTNIA/exec" method="post">
<div class="email-name">
<input id="name" name="name" type="text" class="form-control" placeholder="write name" autocomplete="off">
</div>
<div class="email-main">
<input id="email" name="email" type="text" class="form-control" placeholder="write email" autocomplete="off">
</div>
<div class="email-subject">
<input id="subject" name="subject" type="text" class="form-control" placeholder="write related sub" autocomplete="off">
</div>
<div class="email-message">
<textarea id="message" name="message" class="form-control" placeholder="write message here"></textarea>
</div>
</form>
<button id="send-email" type="submit">SUBMIT EMAIL</button>
如果这不起作用,您可以尝试将 target
用于隐藏的 iframe。