Reputation: 1586
Is it possible to auto refresh the Twitter timeline widget which we create from Twitter app?
My client want to remove the scroll bar from widget and auto refresh it every 30 seconds. I found below Chrome plugin for that but I feel that we can't force every user to install it in their browsers.
Any ideas???
UPDATE:
I just wrote a function for this, please correct me if I am wrong
<script>
$(document).ready(
function() {
setInterval(function() {
$('.social-list').load();
}, 30000);
});
</script>
or
<script>
$(document).ready(
function() {
setInterval(function() {
$('#twitter-widget-1').load($('#twitter-widget-1'));
}, 3000);
});
</script>
social-list is the parent div, twitter-widget-1 is the iframe id
Upvotes: 1
Views: 7434
Reputation: 715
In case this applies to anyone else arriving here, just spotted that if you have a data-tweet-limit
customisation on the widget, for some reason the widget will not poll for new updates - see: https://twittercommunity.com/t/embedded-timeline-widget-does-not-update-after-customization/36299 which points to: https://dev.twitter.com/web/embedded-timelines. Removing that customization sorted out my refreshing problems - it appears to poll for new tweets every 30s or so.
Upvotes: 3
Reputation: 392
<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"));
twttr.ready(function (twttr) {
twttr.widgets.load();
setInterval(function() {
twttr.widgets.load();
console.log("update twitter timeline each second");
}, 1000);
});
</script>
jsfiddle demo: http://jsfiddle.net/9x9fc/194/
Upvotes: 3