[英]Object doesn't support property or method 'stop' IE
When i click on submit button. 当我点击提交按钮。 I got an error like "Object doesn't support property or method stop " in Internet Explorer but data is successfully added in database.
我在Internet Explorer中收到类似“对象不支持属性或方法停止”的错误,但数据已成功添加到数据库中。
Here is my code. 这是我的代码。
function SaveComment(subCommentId, trShowresponseId, tdShowresponseId, startDate, endDate) {
// alert("");
debugger;
try {
var response = document.getElementById("TextBoxResponse~" + subCommentId).value;
if (response === "") {
alert("Please Enter Response.");
return false;
}
else {
// var isAdvanceComment = 1;
$("#showloading").show();
var commentType = 'A';
var returnReult = dashboards_DiscreteRating.SaveComment(response, subCommentId, commentType, startDate, endDate, 0).value;
if (returnReult.match("Error")) {
document.getElementById("spanErrorMessage").innerHTML = returnResponse;
}
else {
document.getElementById(tdShowresponseId).innerHTML = returnReult;
}
// document.getElementById(tdShowresponseId).innerHTML = dashboards_DiscreteRating.SaveComment(response, subCommentId, commentType, 0).value;
document.getElementById("trHiddenTextBox~" + subCommentId).className = "hide";
document.getElementById("trAddSpan~" + subCommentId).className = "show";
document.getElementById("TextBoxResponse~" + subCommentId).value = "";
document.getElementById(trShowresponseId).className = "show";
$("#showloading").hide();
window.stop();
}
}
catch (ex) {
alert(ex.description);
}}
See https://developer.mozilla.org/en-US/docs/Web/API/Window/stop 参见https://developer.mozilla.org/en-US/docs/Web/API/Window/stop
The stop() method is not supported by Internet Explorer.
Internet Explorer不支持stop()方法。
Also: I don't know what you are trying to achieve by calling stop()
. 另外:我不知道您要通过调用
stop()
来实现什么。
However: you call window.stop();
但是:您调用
window.stop();
as the last line in your file. 作为文件的最后一行。 Since you don't rollback in your
catch
-block or anything, everything before that call (eg writing to database) gets executed and not rolled back 由于您不回滚
catch
-block或其他任何内容,因此该调用之前的所有内容(例如,写入数据库)都将执行且不会回滚
Instead of using window.stop()
, return false
or call preventDefault
on the event object in the form's submit
listener – likely wherever you call SaveComment
. 代替使用
window.stop()
,返回false
或在表单的submit
侦听器中的事件对象上调用preventDefault
-可能在您调用SaveComment
任何SaveComment
。 Something along the lines of: 类似于以下内容:
commentForm.addEventListener('submit', function (e) {
// …
SaveComment(…);
e.preventDefault();
});
The alert here suggests you might already be passing the return value straight through: 这里的警报表明您可能已经直接将返回值传递给了:
alert("Please Enter Response.");
return false;
in which case you should be able to do it here too: 在这种情况下,您也应该可以在这里进行操作:
$("#showloading").hide();
return false;
Finally i solved this error by using this . 最后,我使用this解决了这个错误。
function SaveComment(subCommentId, trShowresponseId, tdShowresponseId, startDate, endDate) {
// alert("");
debugger;
try {
var response = document.getElementById("TextBoxResponse~" + subCommentId).value;
if (response === "") {
alert("Please Enter Response.");
return false;
}
else {
// var isAdvanceComment = 1;
$("#showloading").show();
var commentType = 'A';
var returnReult = dashboards_DiscreteRating.SaveComment(response, subCommentId, commentType, startDate, endDate, 0).value;
if (returnReult.match("Error")) {
document.getElementById("spanErrorMessage").innerHTML = returnResponse;
}
else {
document.getElementById(tdShowresponseId).innerHTML = returnReult;
}
// document.getElementById(tdShowresponseId).innerHTML = dashboards_DiscreteRating.SaveComment(response, subCommentId, commentType, 0).value;
document.getElementById("trHiddenTextBox~" + subCommentId).className = "hide";
document.getElementById("trAddSpan~" + subCommentId).className = "show";
document.getElementById("TextBoxResponse~" + subCommentId).value = "";
document.getElementById(trShowresponseId).className = "show";
$("#showloading").hide();
if ($.browser.msie) { //************** Here is the answer ************
document.execCommand('Stop'); //************** Here is the answer ***********
}
else {
window.stop();
}
}
}
catch (ex) {
alert(ex.description);
}}
Internet Explorer does not support window.stop() so we can use document.execCommand("Stop") for IE. Internet Explorer不支持window.stop(),因此我们可以将IE使用document.execCommand(“ Stop”) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.