Twitter widgets.js抛出JavaScript错误“预期标识符”在IE8上 [英] Twitter widgets.js throws JavaScript error "Expected identifier" on IE8

查看:414
本文介绍了Twitter widgets.js抛出JavaScript错误“预期标识符”在IE8上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Internet Explorer 8(IE8)上运行Twitter for Web widgets.js时遇到任何人遇到JavaScript错误?
如果是这样,你知道如何解决这个问题或如何优雅地处理它吗?

Anybody run into a JavaScript error when trying to run Twitter For Web widgets.js on Internet Explorer 8 (IE8)? If so, do you know how to fix this or how to handle it gracefully?

CODE
只需添加这段代码,加载widgets.js文件在IE8上抛出错误:

CODE Just adding this block of code, which loads the widgets.js file throws an error on IE8:

<script>
window.twttr = (function (d, s, id) {
  var t, js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src= "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);
  return window.twttr || (t = { _e: [], ready: function (f) { t._e.push(f) } });
}(document, "script", "twitter-wjs"));
</script>

我得到的代码段为: https://dev.twitter.com/web/javascript/loading

IE8中的错误


网页错误详情

Webpage error details

用户代理:Mozilla / 4.0(兼容; MSIE 8.0) ; Windows NT 6.1; WOW64;
Trident / 4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; Media Center PC 6.0; .NET4。 0C; .NET4.0E)时间戳:星期四,2015年1月29日00:54:28 UTC

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) Timestamp: Thu, 29 Jan 2015 00:54:28 UTC

消息:脚本错误行:0字符:0代码:0 URI:
https://platform.twitter.com/widgets.js

Message: Script error Line: 0 Char: 0 Code: 0 URI: https://platform.twitter.com/widgets.js

这没有帮助,但在开发人员工具中,在脚本下我得到以下消息:

That was not helpful, but in the Developer tool, under Script I get the following message:


(X)预期标识符widgets.js,第1行字符29036

(X) Expected identifier widgets.js, line 1 character 29036

我也在调查并发现Twitter去年(2014年)停止了对IE7的全面支持,并在2015年1月初停止对IE8的支持。我不确定这是否是他们的widgets.js导致错误的原因,但我还是需要弄清楚在没有在IE8上抛出错误的情况下加载此脚本的最佳方法是什么。谢谢!

I also investigated and found that Twitter stopped fully supporting IE7 last year (2014) and is stopping support for IE8 early in January 2015. I'm not sure if this is why their widgets.js causes an error or not, but I still need to figure out what the best way is to load this script without throwing an error on IE8. Thank you!

推荐答案

找到解决方案,

在小部件中。 js,有一个名称为delete的方法(第364行)

In widgets.js, there is a method which name is "delete" (line 364)

"delete": function(t) {
     var e = i(t),
     n = this.get(e.slice(0, -1));
     n && delete n[e.slice(-1)]
 },

此方法调用在1364行

and this method calling on line 1364

l.delete(["callbacks", t.callbackName])

删除在保留字列表。因此它会导致预期的标识符错误。

delete is in Reserved Words list. So it causes "Expected identifier" error.

首先,将widgets.js带到您自己的主机。

Firstly, take widgets.js to your own host.

js.src= "http://www.yourdomain.com/widgets.js";

更改此域名。


在该步骤之前或之前在widgets.js中,必须更改删除
方法名称和来电者行。

这篇关于Twitter widgets.js抛出JavaScript错误“预期标识符”在IE8上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆