如果您可以将计算算法转换为可以迭代调用的内容,则可以使用具有短超时值的setTimeout以频繁的间隔释放控制权。例如,像这样......function doCalculation(){ //do your thing for a short time //figure out how complete you are var percent_complete=.... return percent_complete;}function pump(){ var percent_complete=doCalculation(); //maybe update a progress meter here! //carry on pumping? if (percent_complete<100) { setTimeout(pump, 50); }}//start the calculationpump();