Javascript determines whether flash loads the completed code _javascript tips

Source: Internet
Author: User
First define the progress bar display layer:
Copy Code code as follows:

<div><span class= "Intro" > Download Progress:</span>
<div class= "Barborder" >
<div class= "Bar" id= "Loadpercent" ></div>
</div>
</div>

Define AD layer:
Copy Code code as follows:

<div id= "Showad" ></div>
Define Flash Display layer:
<div id= "showswf" class= "show" style= "Display:none;" >
<object id= "FlashGame" ... Omit content ......>
</object>
</div>

JS Code:
Copy Code code as follows:

<script language= "JavaScript" >
if (Window.navigator.userAgent.indexOf ("Firefox") >=1)/To determine whether it is a Firefox browser, Firefox does not support percentloaded () function
{
document.getElementById ("Loadpercent"). Innerhtml= "firefox! No attentions ";
document.getElementById ("showswf"). style.display= ' block ';
}
Else
{
Refreshprogress ();
}

function Show ()//Hide ad layer, display flash layer
{
document.getElementById ("Showad"). style.display= ' None ';
document.getElementById ("showswf"). style.display= ' block ';
}

function refreshprogress ()//Refresh progress bar functions
{
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);
}
}

In fact, the best code is to see some flash game site, is how to control, look at the source code can understand more knowledge and skills.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.