javascript - Twitter 按钮在 IE8 中导致 JS 错误(预期标识符)

标签 javascript twitter internet-explorer-8

我在我的页面上添加了一个 Twitter 按钮,使用的代码来自 https://about.twitter.com/resources/buttons

一个非常基本的实现如下所示

<!DOCTYPE html>
<html>

<head>
</head>

<body>

<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

</body>

</html>

在所有浏览器中都能完美运行,但 IE8 除外,它会触发错误:SCRIPT1010:预期标识符 文件:widgets.js,行:1,列:29036

在文件 https://platform.twitter.com/widgets.js

我不明白我的实现怎么可能是错误的。有谁知道或者这真的是 Twitter 代码中的 IE8 错误吗?

最佳答案

根据Twitter widgets.js throws JavaScript error "Expected identifier" on IE8 ,Twitter 于 2015 年 1 月停止支持 IE8。

因此,我的“解决方案”是使用条件注释 <!--[if gt IE 8]><!--> TWITTER CODE HERE <!--<![endif]--> 在 IE8 及更低版本中禁用推文按钮。

关于javascript - Twitter 按钮在 IE8 中导致 JS 错误(预期标识符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28178051/

相关文章:

internet-explorer-8 - 如果背景颜色存在,IE8 渐变过滤器不工作

css - IE8 : Disable cleartype?

javascript - React JS 在另一个组件内调用函数

Twitter 速率限制 IP/OAuth 问题

python - 在 Python 中挖掘两个日期之间的推文

python - python 中的 oauth2

html - IE8 仅使用 css 在图像上方垂直居中对齐跨度?

javascript - 以 Angular 向表格添加滚动条

javascript - 使用 $http 刷新来自服务的数据时, Angular View 不更新

javascript - 特定 anchor 链接的平滑滚动