2014-01-29 29 views
0

我有一个窗体,当提交时,我想让窗口在弹出窗口中,但在此之前我需要警告。如果我做到以下几点:onsubmit表单,警告用户并在弹出窗口中打开?

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.');" 

这将打开弹出然后显示一个警告,把窗口后面弹出并开展用户按下OK之前或取消形式的结果。如果我切换它们并在弹出窗口之前放置警告,它只会在新选项卡中打开,而不是以固定大小弹出。你能帮忙吗?完整形式的代码如下:

<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> 

回答

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> 
0

你想干什么

if(confirm("...")) { 
    window.open(...); 
} else { 
    return false; 
} 
相关问题