Twitter button causing JS error in IE8 (Expected identifier)

不羁的心 提交于 2019-12-12 02:03:38

问题


I included a Twitter button on my page, using the code from https://about.twitter.com/resources/buttons

A very basic implementation looks like this

<!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>

Is runs perfectly in all browsers, except IE8, where it triggers an error: SCRIPT1010: Expected identifier File: widgets.js, Line: 1, Column: 29036

in file https://platform.twitter.com/widgets.js

I don't see how my implementation could be wrong. Does anyone have an idea or is this really an IE8 bug in the Twitter code?


回答1:


According to Twitter widgets.js throws JavaScript error "Expected identifier" on IE8, Twitter stopped supporting IE8 in January 2015.

My "solution" was therefore to use conditional comments <!--[if gt IE 8]><!--> TWITTER CODE HERE <!--<![endif]--> to disable the tweet button in IE8 and lower.



来源:https://stackoverflow.com/questions/28178051/twitter-button-causing-js-error-in-ie8-expected-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!