In one of my former posts '' I ended the post with the statement that it didn't work in Internet explorer. So true, but I have a workaround for this now which make multiple user tweets display the same way no matter which browser is used.
Use the same approach described in the former post for Firefox, Safari etc. For Internet Explorer the solution is to use iframes. Since there seems to be a problem displaying several user tweets in the same window instead we will display several windows, where each one contains tweets for only one user,
Create an html-file (referred to as 'tweetsNW.html' below) for each user which have the following syntax:
<link rel="stylesheet" type="text/css" href="css/style.css" /> <a href="http://twitter.com/nickwick76" title="Follow Nic on Twitter" target="_blank"><img src="http://www.wohill.com/images/wo_nick.jpg" style="margin:3px 0 0 0" /></a> <div id="twitterNW" align="left" style="margin:0 0 0 15px"> <p>Please wait while my tweets load <br /><img src="http://www.wohill.com/images/wo_ajax_loader.gif" /></p> <p><a href="http://twitter.com/nickwick76" target="_blank">If you can't wait - check out what I've been twittering</a></p> </div>
<script src="http://www.wohill.com/js/twitter.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" charset="utf-8"> <!-- Get twitters --> getTwitters('twitterNW', { id: 5549092, count: 2, enableLinks: true, ignoreReplies: true, prefix: '<span style=\"color:#0000FF\">Nic said </span>', clearContents: true }); </script> |
In the file where you want to display the tweets, use
conditional statements for html to decide which code to run depending on if the browser is IE or not.
For Internet Explorer use:
<!--[If IE]> HTML CODE TO RUN <![endif]--> |
For non-Internet Explorer use:
<!--[if !IE]>--> HTML CODE TO RUN (i.e. the code we used in the former post) <!--<![endif]--> |
So if the browser is Internet Explorer use a script block like this for each user:
<script type=\"text/javascript\"> <!-- who = \"NW\" inwidth = 180; //--> </script> <script src=\"http://www.wohill.com/js/tweetsplugin.js\" type=\"text/javascript\"> </script> |
What happens here is that two variables are set; 'who' and 'inwidth'. The 'who'-variable is specific to the user which we can see in the js plugin-file below. The variable 'inwidth' specifies the width of the iframe, which will be rendered by the script below. Depending on the value of the 'who'-variable different source files are set for the iframe and also different iframe id's:
function show_presence() { if (who == "RG") { var iframeId = "myframe1"; var tlink = " src=\"http://www.wohill.com/include/tweetsRG.html\""; } if (who == "NW") { var iframeId = "myframe2"; var tlink = " src=\"http://www.wohill.com/include/tweetsNW.html\""; } document.write("<ifr" + "ame" + " id=\"" + iframeId + "\"" + " name=\"tweetsIframe\"" + " width=\"" + inwidth + "\"" + " frameborder=\"0\"" + tlink + " marginwidth=\"1\"" + " marginheight=\"0\"" + " vspace=\"0\"" + " hspace=\"0\"" + " allowtransparency=\"true\"" + " scrolling=\"no\"" + " style=\"overflow:visible; display:none\">"); document.write("</ifr" + "ame>"); } show_presence(); |
So this is what we need to make it look the same way no matter what browser you use. One thing you might think of if you implement this is that, even though you haven't specified a height for the iframe there is still some overflow. There is a way to get passed this and to get dynamic iframe height as well. Just include some JavaScript code in the header of the main file and you're done. Have a look at , where I found it, for further instructions.