【发布时间】:2012-07-19 08:39:22
【问题描述】:
我正在使用 JQuery 截取表单,但它在任何版本的 IE 中都不起作用。有没有人有任何提示?我尝试了 form.submit() 但发现它在 Firefox 中存在问题。任何帮助将不胜感激。
$(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;
});
【问题讨论】:
-
e.originalEvent.explicitOriginalTarget在 IE 中可用吗? -
e.explicitOriginalTarget是 Mozilla 特有的。 -
我没有专门使用该代码,但非常相似。只需返回 true 即可发送表单,如果出现错误则阻止默认设置。
-
试试 e.stopPropogation 或检查stackoverflow.com/questions/4479216/…
-
你有任何名称为“提交”的输入元素,这可能是问题
标签: javascript jquery forms internet-explorer submit