If you use the HTML/Javascript Twitter badge, you've probably noticed that it has issues under Internet Explorer. It will generally work the first time a user hits the page, but if the next time, the badge will not show a tweet list. Here is a work-around you can use if you have access to your blog's code.
Note: Unfortunately, you won't be able to do this if you're on Blogger, MySpace, Facebook or some other shared that doesn't allow you to write server-side code.
The problem is with the way IE handles caching. One quick way to work around this if you can write code on your site is to add a randomized parameter to the code that retrieves the JSON timeline.
For example, in PHP, you could do something like this:
In the badge code, change the following line:
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/yourusername.json?callback=twitterCallback2&count=1"></script>to:
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/yourusername.json?callback=twitterCallback2&count=1&rand=<?php echo rand(1,10000); ?>"></script>This causes IE to treat every request as new and not cache it.
Update: Good news for shared blog users! John Cosgrave has a pure Javascript version of this hack at the Twitter Get Satisfaction support site. Scroll down through the comments and look for John's version.
Update II: More good news! Twitter has supposedly fixed the problem on their end, so these hacks should no longer be necessary. I haven't had a chance to try it yet, but other users report that it works.
Comments
So is this really a JS wrapper to the twitter API, or do I really need PHP? I want a JS only wrapper, written in OO JS.
It's just a small script that uses the Twitter JSON API to retrieve a tweet list. Fortunately, since this was posted, Twitter fixed the IE badges, so you shouldn't need this work-around any more.
Have a look at jQuery if you are not already familiar with it. It meshes very well with the Twitter API and should be a good choice for creating OO Twitter apps.
Post new comment