1. js加载图片进度条应该怎么写
var jsload = {img: [ 'about.png', 'applyBtn.png', 'background2.png', 'bgImg.png', 'bird.cman.png', 'borad2.png','choujiang.png','entry.png','f_0.png','f_1.png','f_2.png','f_3.png','f_4.png','f_5.png','f_6.png','f_7.png','f_8.png','f_9.png','fxFBfont.png','ground.2.png','logo.png','pgBar.png','pgBg.png','pipe2.png','raffle.png','rank.png','rankBtn.png','ruleBtn.png','shareButton.png','shareImg.png','sureBtn.png','tap.png','titleImg.png','trymore.png'],count: 1,go: 1,init: function () {var _this = this;$.get('dom.txt', function (response) {$('#gameDiv').append(response);_this.move();});this.count += this.img.length;this.go = this.count;this.loadImg();},loadImg: function () {for (var i = 0; i < this.img.length; i++) {var img = new Image();var _this = this;img.onload = function () {_this.move();};img.src = 'resource/assets/' + this.img[i];};return this;},move: function () {--this.go;var press = Math.round((this.count - this.go) / this.count * 100);console.log('游戏加载进度', press);// if(press === 100){// start.init();// }}};jsload.init();图片 和txt加载 可以参考下。
2. js加载图片进度条应该怎么写
var jsload = {
img: [ 'about.png', 'applyBtn.png', 'background2.png', 'bgImg.png', 'bird.cman.png', 'borad2.png',
'choujiang.png','entry.png','f_0.png','f_1.png','f_2.png','f_3.png',
'f_4.png','f_5.png','f_6.png','f_7.png','f_8.png','f_9.png',
'fxFBfont.png','ground.2.png','logo.png','pgBar.png','pgBg.png','pipe2.png',
'raffle.png','rank.png','rankBtn.png','ruleBtn.png','shareButton.png',
'shareImg.png','sureBtn.png','tap.png','titleImg.png','trymore.png'
],
count: 1,
go: 1,
init: function () {
var _this = this;
$.get('dom.txt', function (response) {
$('#gameDiv').append(response);
_this.move();
});
this.count += this.img.length;
this.go = this.count;
this.loadImg();
},
loadImg: function () {
for (var i = 0; i
3. js怎么实现进度条
就是要用setInterval setTimeout
慢慢的改变div的宽,好像一点一点涨到100%
for(var i=0;i<100;i++)
{
for(var j=0;j<10000;j++)
{
var width = $("#progressBar").width();
width+=1;
$("#progressBar").width(width);
//这样不行 是因为for循环在很短的时间内执行完毕你根本看不出来
}
}
4. 用javascript写的进度条,怎么获取进度条的值,按百分比显示出来
s[0].style.width = 100 - r / i * 100 + "%";该代码不就是设置进度条的么
如果你能更改页面 你在标签中这样写:
(资料完整度
)然后在你的js中
s[0].style.width = 100 - r / i * 100 + "%";的下面 写上:
document.getelementbyid("wz_jd").innerhtml = 100 - r / i * 100 + "%";不就ok了么
注意:你的js中哪儿有那行代码 就在那行下面 追加
如果不能更改页面就在那行代码下面 这样写:
document.getelementsbytagname("h5")[0].innerhtml = "(资料完整度"+ (100 - r / i * 100) + "%)";里面的0 表示是第1个h5标签 如果你有多个 自己进行更改
5. JS实现使用符号制作的进度条代码怎么写呢
html xmlns= headtitle标题页-学无忧()/title/headbodyform name=loading p align=center font color=#0155cc size=2 face=Arial页面载入中,请稍等。
/fontbr input type=text name=progress size=46 style=font-family:Arial; font-weight:bolder; color:#0066ff; background-color:#fef4d9; padding:0px; border-style:none; br input type=text name=percent size=47 style=color:#0055BB; text-align:center; border-width:medium; border-style:none; script language=javascript var bar=0; //进度条的进度 var line=|| ; //类似进度条的符号 var amount=|| ; count() ; function count(){ bar=bar+2 ; //进度条+2 amount =amount + line ; //符号也跟着增加 document。 loading。
progress。value=amount ; //进度条显示符号 document。
loading。percent。
value=bar+% ; //现实进度 if (bar100) //判断进度条是否已经到头 setTimeout(count(),100); else window。 location = #; } /script /p/form /body/html。
6. 如何用 javascript 做一个高逼格的进度条
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RunJS</title>
<style>
#progress{
border:1px solid black;
width:500px;
height:20px;
text-align:center;
}
#progress>div{
width:0px;
height:20px;
position:absolute;
background-color:yellow;
}
#progress>span{
color:red;
position:absolute;
}
</style>
<script type="text/javascript">
onload = function(){
var div = progress.querySelector("div");
var span = progress.querySelector("span");
var pw = parseFloat(progress.style.width) || parseFloat(getComputedStyle(progress).width) || progress.offsetWidth;
var interval = setInterval(function(){
var w = parseFloat(div.style.width) || parseFloat(getComputedStyle(div).width) || div.offsetWidth;
w+=10;
if(w>=pw){
w = pw;
clearInterval(interval);
}
div.style.width = w + "px";
span.innerHTML = w*100/pw + "%";
},60);
};
</script>
</head>
<body>
<div id="progress">
<div>
</div>
<span></span>
</div>
</body>
</html>
7. 原生javascript怎样写环形进度条
一、序言
一直很中意win8等待提示圆圈进度条。win8刚出来那会,感觉好神奇!苦于当时没思路,没去研究。通过最近网上找找资料,终于给搞出来了!先上Demo,献丑了!预览请看:win8进度条。
二、简单介绍
原生javascript编写,需要理解js基于面向对象编程和圆形坐标计算!
实现原理:把每个圆点抽象成一个对象(ProgressBarWin8类型),将每个圆点对象存在数组中(progressArray),延迟执行每个圆点对象的run方法,至于圆点运行速度越来越快,是通过改变定时器延迟毫秒数实现的。
复制代码 代码如下:
// 判断元素x与圆心x坐标大小,设置定时器延迟时间
if (this.position.left
8. 如何用JS编写进度条形式的下载效果
【实例代码】htmlheadtitle无标题文档/titleSCRIPT language=javascriptvar NUMBER_OF_REPETITIONS = 40;var nRepetitions = 0;var g_oTimer = null;//开始下载的方法function startLongProcess(){ divProgressDialog。
style。display = ; resizeModal(); btnCancel。
focus(); // 设置窗口为大小可更改模式 window。onresize = resizeModal; //当用户非正常中断时,添加一个提示 window。
onbeforeunload = showWarning; continueLongProcess();}function updateProgress(nNewPercent){ // 更改进度条的进度 divProgressInner。style。
width = (parseInt(divProgressOuter。style。
width) * nNewPercent / 100)+ px;}//取消进度条的方法function stopLongProcess(){ if (g_oTimer != null) { window。 clearTimeout(g_oTimer); g_oTimer = null; } // Hide the fake modal DIV divModal。
style。width = 0px; divModal。
style。height = 0px; divProgressDialog。
style。display = none; // 移除窗体事件 window。
onresize = null; window。onbeforeunload = null; nRepetitions = 0;}//判断进度是否执行完毕的方法function continueLongProcess(){ if (nRepetitions NUMBER_OF_REPETITIONS) { var nTimeoutLength = Math。
random() * 250; updateProgress(100 * nRepetitions / NUMBER_OF_REPETITIONS); g_oTimer = window。setTimeout(continueLongProcess();, nTimeoutLength); nRepetitions++; } else { stopLongProcess(); }}function showWarning(){ //用户非正常退出时的提示信息 return 有一个应用程序正在运行,是否确定要退出;}function resizeModal(){ divModal。
style。width = document。
body。scrollWidth; divModal。
style。height = document。
body。scrollHeight; divProgressDialog。
style。left = ((document。
body。offsetWidth - divProgressDialog。
offsetWidth) / 2); divProgressDialog。style。
top = ((document。body。
offsetHeight - divProgressDialog。 offsetHeight) / 2);}/SCRIPT/headBODY STYLE=FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, HelveticaINPUT TYPE=BUTTON VALUE=开始下载 onclick=startLongProcess();!-- 开始下载 --DIV STYLE=BORDER: buttonhighlight 2px outset; FONT-SIZE: 8pt; Z-INDEX: 4; FONT-FAMILY: Tahoma; POSITION: absolute; BACKGROUND-COLOR: buttonface; DISPLAY: none; WIDTH: 350px; CURSOR: default ID=divProgressDialog onselectstart=window。
event。returnValue=false; DIV STYLE=PADDING: 3px; FONT-WEIGHT: bolder; COLOR: captiontext; BORDER-BOTTOM: white 2px groove; BACKGROUND-COLOR: activecaption 下载对话框 /DIV DIV STYLE=PADDING: 5px 正在下载,请等待。
/DIV DIV STYLE=PADDING: 5px 这个过程需要几分钟 /DIV DIV STYLE=PADDING: 5px DIV ID=divProgressOuter STYLE=BORDER: 1px solid threedshadow; WIDTH: 336px; HEIGHT: 15px DIV ID=divProgressInner STYLE=COLOR: white; TEXT-ALIGN: center; BACKGROUND-COLOR: infobackground; MARGIN: 0px; WIDTH: 0px; HEIGHT: 13px;/DIV /DIV /DIV DIV STYLE=BORDER-TOP: white 2px groove; PADDING-BOTTOM: 5px; PADDING-TOP: 3px; BACKGROUND-COLOR: buttonface; TEXT-ALIGN: center INPUT STYLE=FONT-FAMILY: Tahoma; FONT-SIZE: 8pt TYPE=button ID=btnCancel onclick=stopLongProcess(); VALUE=取消 /DIV/DIV!-- 结束下载 --!-- BEGIN FAKE MODAL DIV--DIV ID=divModal STYLE=BACKGROUND-COLOR: white; FILTER: alpha(opacity=75); LEFT: 0px; POSITION:absolute; TOP: 0px; Z-INDEX: 3 onclick=window。 event。
cancelBubble=true; window。event。
returnValue=false;/DIV!-- END FAKE MODAL DIV --/body/html 【难点剖析】本例的重点是如何判断进度条的进度,其中使用了语句“1 00 * nRepetitionS/NUMBER_OF_REPETITIONS”。 “nRepetitions”变量相当于步长,在此处每增加一个进度“nRepetitions” 变量会自增 “1”。
“NUMBER OF REPETITIONS”是一个常量,其值为“40”。