提交表单,警告用户并在弹出窗口中打开?

时间:2014-01-29 16:05:30

标签: javascript html forms popup submit

我有一个表单,提交时我希望生成的窗口在弹出窗口中,但在此之前我需要一个警告。如果我执行以下操作:

target="DoSubmit" onsubmit=" DoSubmit = window.open('about:blank','DoSubmit','width=500,height=350'); return confirm('Our Twitter account is set to private. If you click OK this will log a call with the Helpdesk and then take you to a page where you can request to follow us. Once we have approved the request you will be able to see our Tweets.');"

这将打开弹出窗口,然后显示警告,将弹出窗口置于窗口后面,并在用户按下确定或取消之前执行窗体的结果。如果我切换它们并在弹出窗口之前发出警告,它只会在新选项卡中打开而不是具有固定大小的弹出窗口。你能帮帮忙吗?完整的表单代码如下:

<form name="TwitterSubscribe" id="TwitterSubscribe" action="./logconfirm_Twitter.php" method="post" target="DoSubmit" onsubmit=" DoSubmit = window.open('about:blank','DoSubmit','width=500,height=350'); return confirm('Our Twitter account is set to private. If you click OK this will log a call with the Helpdesk and then take you to a page where you can request to follow us. Once we have approved the request you will be able to see our Tweets.');">
          <input type="image" src="./images/twitter.png" onmouseover="this.src='./images/twitterHover.png';" onmouseout="this.src='./images/twitter.png';" />
          </form>

2 个答案:

答案 0 :(得分:0)

你想做

if(confirm("...")) { 
    window.open(...); 
} else { 
    return false; 
}

答案 1 :(得分:0)

你可以这样做:

<body>
...
<form id="myForm" action="x">
    <input type="submit" onclick="validateSubmit();return false;" />
</form>
<script>
function validateSubmit() {
    result = confirm("Our Twitter account is set to .....");
    if (result) {
        $('#myForm').submit();
    }
}
</script>
...
</body>
相关问题