2010-07-08 84 views

回答

0

如果你真的需要它是準確的,你需要繪製它的客戶端,最有可能的。您的PHP腳本可以返回描述進度條位置的JSON對象,然後您的腳本將繪製它。下面是從SO另一個問題是列出了一些JavaScript的圖形選項:Which JavaScript graphics library has the best performance?

0

PHP

$purchased_num = 13; // items purchased until now (example) 

$max_width = 400; // the width of the bar 
$max_pur = 50; // the maximum number of items 
$one_pur_width = round($max_width/$max_pur); 

$width = $one_pur_width * $purchased_num; 

// print the div with this width 
// and style the bar with css 
// ... 

1

你應該使用jQuery經常重新加載小部分。

<div id="progBar"> 
</div> 

<script type=text/javascript> 
function refreshProgress() { 
    $.get('/folder/progbar.php', function (data) { 
     $('#progBar').html(data); 
    } 
    setTimeout('refreshProgress();',10000); 
} 

$(function() { refreshProgress(); }); 
</script> 

當加載頁面時會加載progbar.php(這將基於在銷售時的當前進度條)入格,並刷新每10秒。