将电子邮件输入发送到弹出窗口

时间:2014-10-26 18:45:18

标签: javascript html

我为my blog制作了这段代码和脚本 - 它是针对联系页面的,我有一个问题。我想将提供的电子邮件发送到弹出窗口,以便用户无需重新输入。但似乎无法让它发挥作用。我已经在提交按钮中添加了一个事件,因为该代码仅用于联系表单(这是一个博客代码,我无法访问该脚本。)

HTML:

<form name="contact-form">Hvad skal jeg kalde dig?
<br />
<input class="contact-form-name" id="ContactForm1_contact-form-name" name="name" placeholder="Skriv dit navn her ..." size="40" style="margin-top: 10px;" type="text" value="" />
<br />
<br />Hvordan svarer jeg dig? <span id="required">*</span>

<br />
<input class="contact-form-email" id="ContactForm1_contact-form-email" name="email" placeholder="Indtast din email her ..." size="40" style="margin-top: 10px;" type="text" value="" />
<br />
<br />Hvad vil du gerne fortælle mig?<span id="required">*</span>

<br />
<textarea class="contact-form-email-message" cols="25" id="ContactForm1_contact-form-email-message" name="email-message" placeholder="Skriv din besked til mig her ..." rows="8" style="margin-top: 10px;"></textarea>
<br />
<br />
<input type="checkbox" id="nyhedsbrev">Tilmeld dig mit nyhedsbrev</p>
<input name='uri' type='hidden' value='ThingsThatMadeMe' />
<input name='loc' type='hidden' value='en_US' />
<input class="contact-form-button contact-form-button-submit2" id="ContactForm1_contact-form-submit" size="40" type="button" value="Send din besked" onclick="myFunction()">
<br />
<br />
<div class="contact-form-error-message" id="ContactForm1_contact-form-error-message"></div>
<div class="contact-form-success-message" id="ContactForm1_contact-form-success-message"></div>
</form>

脚本:

<script>
document.getElementById("ContactForm1_contact-form-submit").addEventListener("click", myFunction);

function myFunction() {

    if (document.getElementById('nyhedsbrev').checked) window.open("https://feedburner.google.com/fb/a/mailverify?uri=ThingsThatMadeMe", "popupwindow", "toolbar=yes, scrollbars=yes,width=550, height=520 method=post action=https://feedburner.google.com/fb/a/mailverify?");
}
</script>

此代码一般工作正常。这只是一件事,这让我感到烦恼。

1 个答案:

答案 0 :(得分:0)

在关闭BODY标记之前移动您的JS代码,即</body>之前或FORM代码之后。

您可以在此处查看工作演示:http://jsfiddle.net/7j8s0wen/2/