JS 文件未在 IE 上加载,在 Joomla Seblod 中适用于 Chrome
JS file not loading on IE, works on Chrome in Joomla Seblod
我在 Joomla Seblod 上添加了 JS 作为一个字段,它在我的文件系统中调用一个 JS 文件 my_profile.js 如下-
jQuery.getScript("/components/com_msp/js/my_profile.js")
.done(function(script, textStatus) {
console.log('inside success in seblod');
main();
}).fail(function( jqxhr, settings, exception ) {
console.log('JS failed in seblod..');
console.log(JSON.stringify(jqxhr));
console.log( "Error:" + settings + ' : ' + exception );
});
在 Chrome 上,JS 被正确调用并且所有代码都有效(我也在 Inspect 控制台上收到 inside success in seblod
消息),但是在 IE 上我在控制台上收到了这个消息-
The code on this page disabled back and forward caching.
JS failed in seblod..
Error:parsererror : SyntaxError: Expected identifier
文件中的代码和所有内容都是一样的。直到昨天我也能在IE上看到变化。
parsererror : SyntaxError: Expected identifier
至于这个错误,这意味着您在需要标识符的上下文中使用了标识符以外的东西。标识符可以是:
- 一个变量,
- 一个 属性,
- 一个数组,
- 或函数名称。
请检查您的 JS 脚本,并更改标识符表达式。
您也可以参考this thread and this question。
parsererror : SyntaxError: Expected identifier
实际上导致 IE 上的 JS 代码出现问题。我不得不逐行调试,最后在导致此问题的代码中找到了 2 个实例-
我用它来遍历一个对象- for(const [serial, dates] of Object.entries(data)) {
。必须用更简单的 for...in 循环来替换它,例如 - for (var serial in data){ if (data.hasOwnProperty(serial)) {
我在我的脚本中使用 sweetalert 并在其中使用 .then((result) => {
,在一些挖掘中我发现 IE 不接受箭头运算符。因此,我没有在 sweetalert 操作上使用 queue
并且基本上执行相同的步骤但没有箭头运算符。
我在 Joomla Seblod 上添加了 JS 作为一个字段,它在我的文件系统中调用一个 JS 文件 my_profile.js 如下-
jQuery.getScript("/components/com_msp/js/my_profile.js")
.done(function(script, textStatus) {
console.log('inside success in seblod');
main();
}).fail(function( jqxhr, settings, exception ) {
console.log('JS failed in seblod..');
console.log(JSON.stringify(jqxhr));
console.log( "Error:" + settings + ' : ' + exception );
});
在 Chrome 上,JS 被正确调用并且所有代码都有效(我也在 Inspect 控制台上收到 inside success in seblod
消息),但是在 IE 上我在控制台上收到了这个消息-
The code on this page disabled back and forward caching.
JS failed in seblod..
Error:parsererror : SyntaxError: Expected identifier
文件中的代码和所有内容都是一样的。直到昨天我也能在IE上看到变化。
parsererror : SyntaxError: Expected identifier
至于这个错误,这意味着您在需要标识符的上下文中使用了标识符以外的东西。标识符可以是:
- 一个变量,
- 一个 属性,
- 一个数组,
- 或函数名称。
请检查您的 JS 脚本,并更改标识符表达式。
您也可以参考this thread and this question。
parsererror : SyntaxError: Expected identifier
实际上导致 IE 上的 JS 代码出现问题。我不得不逐行调试,最后在导致此问题的代码中找到了 2 个实例-
我用它来遍历一个对象-
for(const [serial, dates] of Object.entries(data)) {
。必须用更简单的 for...in 循环来替换它,例如 -for (var serial in data){ if (data.hasOwnProperty(serial)) {
我在我的脚本中使用 sweetalert 并在其中使用
.then((result) => {
,在一些挖掘中我发现 IE 不接受箭头运算符。因此,我没有在 sweetalert 操作上使用queue
并且基本上执行相同的步骤但没有箭头运算符。