3
我正在使用JQuery攔截表單,但它不適用於任何版本的IE。有沒有人有任何提示?我試過form.submit(),但發現它在Firefox中有問題。任何幫助將不勝感激。使用JQuery攔截表單在IE中失敗
$(document).ready(function() {
$("form").submit(function(e) {
if (e.originalEvent.explicitOriginalTarget.id == "myButton") {
if (some status is true continue to submit the form)
return true;
//If the status above is false continue to prompt the user if they want to submit or not
var ok = confirm('Do you really want to save your data?');
if (ok) {
return true;
}
else {
//Prevent the submit event and remain on the screen
e.preventDefault();
return false;
}
}
});
return;
});
IE中是否提供了'e.originalEvent.explicitOriginalTarget'? – alex 2012-07-20 04:56:13
'e.explicitOriginalTarget'是Mozilla特有的。 – undefined 2012-07-20 05:03:30
我沒有專門使用該代碼,但非常相似。只是發送表單返回true,並且如果發生錯誤,則阻止默認設置。 – JCraine 2012-07-20 05:05:30