The code that Iâm using (hopefully this will display OK here!)
function loadTwitter(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = â//platform.twitter.com/widgets.jsâ;
fjs.parentNode.insertBefore(js, fjs);
}
}
function removeTwitter(id) {
$(âscript[id=â + id + â]â).remove(); // Remove the included js file
$(âiframe.twitter-timelineâ).remove(); // Remove the timeline iframe
}
function addTwitter(options) {
var linkStr = 'Tweets by â + options.widgetuser + ââ;
$(linkStr).appendTo(options.element);
}
function showTwitter(id, options) {
removeTwitter(id);
addTwitter(options);
loadTwitter(document, âscriptâ, id);
}
Then when I load up one of my hidden divs I call the showTwitterFunction like this:
showTwitter(âtwitter-wjsâ,{element:â#yourdivIDorClassâ,widgetid:â123096637326008320â,widgetuser:âTheUserHereâ});
Please note this uses JQuery