我正在尝试添加onclick
到button
带有动作的表单中。这是一个用于订阅的 mailchimp 操作,因此在他单击按钮后将转到新选项卡中 mailchimp 的成功页面,但还希望在页面中显示带有消息的弹出警报/div,是否可以同时拥有? 同一个提交按钮的action和onclick?
任何想法如何做到这一点?
更新
我的表格如下所示:
<form action="/" method="post" name="form" target="_blank">
<h3><span>Subscribe to Newsletter</span></h3>
<p class="email_first">
<label for="email">Your Email</label>
<input id="EMAIL" class="email" type="email" name="EMAIL" value="Your Email Address:" size="30" />
</p>
<p class="submit"><button type="submit">Send</button></p>
</form>
JavaScript
function popUp(){
var popup = document.createElement('div');
popup.className = 'popup';
popup.id = 'test';
var cancel = document.createElement('div');
cancel.className = 'cancel';
cancel.innerHTML = 'close';
cancel.onclick = function (e) { popup.parentNode.removeChild(popup) };
var message = document.createElement('span');
message.innerHTML = "This is a test message";
popup.appendChild(message);
popup.appendChild(cancel);
document.body.appendChild(popup);
}