jQuery Twitter Widget not populating variables in Safari & IE
A site upon which I'm working is using the following jQuery twitter widget to display feeds:
Simple jQuery twitter w开发者_如何学JAVAidget
Unfortunately, while this widget functions properly on most browsers, the Twitter handles contained within tweets or as part of replies do not display. Instead, Safari & IE are content to just spit out the variable in the script.
I believe the problem may be in how those browsers are interpreting this function:
String.prototype.convertAtToLink = function () {
return this.replace(/\@[A-Za-z0-9]*/, function (str) {
var link = "http://twitter.com/{0}";
link = link.format(str.substr(1));
var rstr = '<a href="{0}">{1}</a>';
return rstr.format(link, str);
});
};
So for example, when in Firefox or another browser, a tweet will appear with RT @username, in Safari it will appear as RT {1}.
Has anyone else encountered this? Is it tied into the ever-present document.ready issue Safari seems to have? Thanks in advance.
Looking at this small block of code, what I have noticed is the difference here:
var rstr = '<a href="{0}">{1}</a>';
You have the {0} in double quotes but not the {1}, perhaps changing this to be consistent will allow both variables to properly display.
精彩评论