Posted in Javascript onApril 12, 2010
先定义进度条显示层:
<div><span class="intro">下载进度:</span> <div class="barborder"> <div class="bar" id="loadpercent"></div> </div> </div>
定义广告层:
<div id="showAD"></div> 定义FLASH显示层: <div id="showSWF" class="show" style="display:none;"> <object id="flashgame" ......省略内容......> </object> </div>
js代码:
<script language="javascript"> if(window.navigator.userAgent.indexOf("Firefox")>=1)//判断是否为FIREFOX浏览器,FIREFOX不支持PercentLoaded()函数 { document.getElementById("loadpercent").innerHTML= "Firefox!No Attentions"; document.getElementById("showSWF").style.display='block'; } else { refreshProgress(); } function show()//隐藏AD层、显示FLASH层 { document.getElementById("showAD").style.display='none'; document.getElementById("showSWF").style.display='block'; } function refreshProgress()//刷新进度条函数 { var downProgressWidth=502; var bar = document.getElementById("loadpercent"); var movie = document.getElementById("flashgame"); var nPercentLoaded = Math.abs(movie.PercentLoaded()); bar.style.width=Math.ceil(downProgressWidth*nPercentLoaded/100) +"px"; bar.innerHTML= nPercentLoaded +"%"; if(nPercentLoaded==100) { bar.style.width=(downProgressWidth-2) + "px"; bar.innerHTML= "Game download is complete"; show(); } else { setTimeout('refreshProgress()',0); } }
其实最好的代码,就是看一些flash游戏网站,是怎样控制,看下源代码就可以了解更多的知识与技巧。
Javascript 判断Flash是否加载完成的代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@