<script type="text/javascript" src="prototype.js"></script> <script type="text/javascript">... function ajaxRequest()...{ var myAjax = new Ajax.Request( 'http://hq.sinajs.cn/list=sh000001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601398,sh601857,sh600028', ...{ method: 'get', onComplete: setData } ); } function setData(response) ...{ var contents = response.responseText; var stocks = contents.split(';'); for(var i=0; i<stocks.length-1; i++)...{ var content = stocks[i]; var temp1 = content.split('=')[0]; var temp2 = content.split('=')[1]; var code = temp1.substr(temp1.length - 6, 6); var temp3 = temp2.replace('"', ''); var name = temp3.split(',')[0]; var tday_f = temp3.split(',')[1]; var yest_f = temp3.split(',')[2]; var curr_f = temp3.split(',')[3]; var temp_f = curr_f - yest_f; $('a'+i).innerHTML = code; $('b'+i).innerHTML = name; $('c'+i).innerHTML = curr_f; if(curr_f > yest_f) ...{ $('c'+i).innerHTML = "<font color='red'>" + curr_f + "</font>"; } else if(curr_f < yest_f) ...{ $('c'+i).innerHTML = "<font color='green'>" + curr_f + "</font>"; } else ...{ $('c'+i).innerHTML = curr_f; } $('d'+i).innerHTML = tday_f; $('e'+i).innerHTML = yest_f; if(temp_f > 0) ...{ $('f'+i).innerHTML = "<font color='red'>" + temp_f.toFixed(2) + "</font>"; $('g'+i).innerHTML = "<font color='red'>" + ((temp_f / yest_f) * 100).toFixed(2) + "</font> %"; } else if(temp_f < 0) ...{ $('f'+i).innerHTML = "<font color='green'>" + temp_f.toFixed(2) + "</font>"; $('g'+i).innerHTML = "<font color='green'>" + ((temp_f / yest_f) * 100).toFixed(2) + "</font> %"; } else ...{ $('f'+i).innerHTML = temp_f.toFixed(2); $('g'+i).innerHTML = ((temp_f / yest_f) * 100).toFixed(2) + " % "; } $('h'+i).innerHTML = temp3.split(',')[4]; $('i'+i).innerHTML = temp3.split(',')[5]; } } function pageInit() ...{ window.setInterval("ajaxRequest()",3000); } </script>