当前位置:开发者网络 >> 网页特效 >> 状态栏类 >> 内容
精彩推荐
分类最新特效
分类热点特效
  
状态栏慢慢计算Pi值
日期:2005-06-15   人气:   【字体: 】【收藏此文


<!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! -->
<!-- 要实现此效果需要 1 个步骤: -->

<!-- 第 1 步: -->
<!-- 把下面的代码加到<BODY></BODY>区域中: -->

<script>
<!--

function pi(name){
this.init = init;
this.compNext = p_compNext;
this.printPi = p_printPi;
this.computePi = p_computePi;
this.runs = new Number();
this.data = new Number();
this.sign = new Number();
this.name = name;
//this.init();
}

function init(){
this.runs = -1;
this.data = 0;
this.sign = -1;
}

function p_computePi(delay){
//eval(this.name+".compNext();");
this.compNext();
if (this.runs %100 == 0) this.printPi();
//eval(this.name+".printPi();");
setTimeout(this.name + ".computePi("+delay+")",delay);
}

function p_printPi(){
//document.pi.pivalue.value = this.data * 4;
window.status = "[" + this.runs + "] > " + this.data * 4;
//document.pi.runs.value = this.runs;
}

function p_compNext(){
this.sign = parseInt(this.sign) * -1;
this.runs = parseInt(this.runs) + 1;
this.data += Math.pow((parseInt(this.runs) * 2 + 1),-1) * this.sign;
}

myPi = new pi("myPi");
myPi.init();
myPi.computePi(1);
//-->
</script>