internet-explorer - Internet Explorer 引发错误并在以下行中退出处理:如何修复它?
问题描述
让 timerId = setInterval(() => { thisisanewguy = "true"; }, 1000);
if (thisisanewguy != "true") {
if (popup == "false") {
if (cancelled2 != "true" && $('[id$=div_contactinfo]').length == 0 && $('[id$=div_specpopup]').length == 0 && $('[id$=familymold]').length == 0 && $('[id$=div_load]').length == 0 &&
$('[id$=painting]').length == 0 && $('[id$=printing]').length == 0 && $('[id$=customprocess]').length == 0 && $('[id$=insert]').length == 0 &&
$('[id$=assembly]').length == 0 && $('[id$=addpart2]').length == 0 && $('#div_background2').css("display") != "block" && $('#div_background').css("display") != "block" && $('#lightbox').css("display") == "none") {
setTimeout(function () {
if (!mouseEnter && cancelled2 != "true" && thisisanewguy != "true") {
$('#alldone').css("display", "block");
$('#div_background2').css("display", "block");
}
}, 5000);
}
else if ($('[id$=div_contactinfo]').length > 0) {
let timerId = setInterval(() => { thisisanewguy = "true"; }, 1000);
// after 10 seconds stop
setTimeout(() => { clearInterval(timerId); thisisanewguy = "false"; }, 10000);
}
}
}
当然其他浏览器都可以。我们今天发现 IE 在这里下降了。而且我还没有弄清楚如何绕过它。我们 8% 的客户仍在使用 IE。
解决方案
我可以看到您在代码中使用了=>箭头函数,Internet Explorer 不支持该函数。
看这里...
参考:
要解决这个问题,您需要将代码从 ES6 转换为 ES5。
你可以使用Babel来编译你的代码。
这是使用 Babel 转译的代码示例。
"use strict";
if (thisisanewguy != "true") {
if (popup == "false") {
if (cancelled2 != "true" && $('[id$=div_contactinfo]').length == 0 && $('[id$=div_specpopup]').length == 0 && $('[id$=familymold]').length == 0 && $('[id$=div_load]').length == 0 && $('[id$=painting]').length == 0 && $('[id$=printing]').length == 0 && $('[id$=customprocess]').length == 0 && $('[id$=insert]').length == 0 && $('[id$=assembly]').length == 0 && $('[id$=addpart2]').length == 0 && $('#div_background2').css("display") != "block" && $('#div_background').css("display") != "block" && $('#lightbox').css("display") == "none") {
setTimeout(function () {
if (!mouseEnter && cancelled2 != "true" && thisisanewguy != "true") {
$('#alldone').css("display", "block");
$('#div_background2').css("display", "block");
}
}, 5000);
} else if ($('[id$=div_contactinfo]').length > 0) {
var timerId = setInterval(function () {
thisisanewguy = "true";
}, 1000); // after 10 seconds stop
setTimeout(function () {
clearInterval(timerId);
thisisanewguy = "false";
}, 10000);
}
}
}
推荐阅读
- selenium - 如何以特定顺序从 xml 文件运行测试
- node.js - expressjs中的中间件函数错误
- javascript - 在 AngularJS 中,console.log 和 $log.info 有什么区别?
- javascript - 编写一个自动填写和提交网络表单程序
- nativescript - 图片转base64返回null
- javascript - 在网页上呈现许多元素的最佳方式?
- javascript - 火狐关闭浏览器
- c# - 使用 iTextSharp(C#,MVC)将 HTML 中的有序列表转换为 PDF
- maven - Appengine Maven 插件排除 node_modules
- c# - WPF Keystroke Dynamics,测量飞行时间的最佳方法?