me and my team really working on a site like www.bidrivals.com/us (penny auction site)
i browse it codes found
<div class="timer online">
<div class="text">00:00:03</div>
</div>
i could not found anything on the js file of this site ... can any body tell me which type of js timer that this site is using? any example code for that? anything available like this in j query or prototype framework ?
Javascript provides the setTimeout
and setInterval
functions to run actions at a "set time" in milliseconds.
https://developer.mozilla.org/en/DOM/window.setTimeout https://developer.mozilla.org/en/window.setInterval
Example:
// this is will act like a counter on the page
var t = 0,
div = document.createElement('div');
div.innerHTML = t;
document.body.appendChild(div);
setInterval(function () {
t += 1;
div.innerHTML = t;
}, 1000); // this will run once every second
In the case of this website, they run an XHR request every second to get the data for each bid. Checkout the console to see the requests.