2011-12-09 21 views
0

我有一個確認框,用戶可以在其中選擇確定繼續或取消關閉框並保持在同一頁面上。問題是,除了Opera,如果我點擊確認框中的取消,那麼所有瀏覽器都會關閉,並且用戶停留在同一頁面上,這很好,但是在Opera中,如果點擊取消,它也會關閉頁面。如果我在確認框上按取消,它會關閉我不想要發生的頁面

我需要包括什麼,才能在Opera中單擊確認框中的取消,它會關閉框但不關閉頁面?

下面

是代碼:

   function showConfirm(){ 

      var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n"); 

      if (confirmMsg==true) 
      { 
      submitform(); 
      }else{ 
      parent.close();  

} 
} 

由於

+0

如果你擺脫了parent.close會發生什麼?我不認爲你想那樣。 – TommyBs

回答

3

在我看來該else塊是不需要的作爲元素的父可以window。這就是頁面關閉的原因。

我不知道你是怎麼想關閉與parent.close()

function showConfirm(){ 
    var confirmMsg=confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards your Session." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n"); 

    if (confirmMsg) 
    { 
     submitform(); 
    } 
} 
+0

嗨,謝謝我使用w3schools的例子,它有一個parent.close(),所以我認爲這是需要與取消按鈕。謝謝 – BruceyBandit

0

上確認框中單擊取消,無論如何都應該閉上你的確認窗口,這是我想你想要做的

http://jsfiddle.net/kRqCd/2/

+0

嗨,謝謝我使用w3schools的例子,它有一個parent.close(),所以我認爲這是需要與取消按鈕。謝謝 – BruceyBandit

相關問題