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 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>
I got this snippet at: https://dev.twitter.com/web/javascript/loading
ERROR in IE8
Webpage error details
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
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) Expected identifier widgets.js, line 1 character 29036
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!