2014-01-29 51 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; 
} 
相關問題