分享
 
 
 

模拟windows control的进度条

王朝html/css/js·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

<HTML><HEAD>

<TITLE>xyProgressLG xo</TITLE>

<script>

function xyProgressLG(xyID){

this.xyProgressID = 'oProgress' + Math.random().toString().substr(2, 10) + xyID;

this.max = 0;

this.min = 0;

this.width = 100;

this.height = 20;

this.currPos = 0;

this.outerBorderColor = "black";

this.outerBackColor = "white";

this.innerBorderColor = "";

this.innerBackColor = "blue";

this.TextColor = "red";

this.SetProgressTop = xySetProgressTop;

this.SetProgressLeft = xySetProgressLeft;

this.SetProgressWidth = xySetProgressWidth;

this.SetProgressHeight = xySetProgressHeight;

this.SetProgressBorderColor = xySetProgressBorderColor;

this.SetProgressForeBorderColor = xySetProgressForeBorderColor;

this.SetProgressBackColor = xySetProgressBackColor;

this.SetProgressForeColor = xySetProgressForeColor;

this.EnableProgressText = xyEnableProgressText;

this.SetProgressTextFontSize = xySetProgressTextFontSize;

this.SetProgressTextFontColor = xySetProgressTextFontColor;

this.SetProgressTextFontFamily = xySetProgressTextFontFamily;

this.SetProgressMax = xySetProgressMax;

this.SetProgressMin = xySetProgressMin;

this.UpdatePosition = xyUpdatePosition;

this.UpdateToPosition = xyUpdateToPosition;

this.UpdatePersent = xyUpdatePersent;

this.UpdateToPersent = xyUpdateToPersent;

xyProgressInit(this.xyProgressID);

return this.xyProgressID;

}

function xyProgressInit(xyID){

var div = document.createElement("div");

div.id = xyID;

div.style.position = "absolute";

div.style.left = "100px";

div.style.top = "100px";

document.body.appendChild(div);

var pro = document.createElement("div");

pro.style.position = "absolute";

pro.style.left = "0px";

pro.style.top = "0px";

pro.style.fontSize= "0px";

pro.style.width = "100px";

pro.style.height = "20px";

pro.style.border = "1px solid black";

pro.style.background = "white";

pro.style.zIndex = "100";

div.appendChild(pro);

var proInner = document.createElement("div");

proInner.id = xyID+"_Inner";

proInner.style.position = "absolute";

proInner.style.left = "1px";

proInner.style.top = "1px";

proInner.style.fontSize= "0px";

proInner.style.width = "0px";

proInner.style.height = "16px";

proInner.style.border = "1px solid black";

proInner.style.background = "blue";

pro.style.zIndex = "102";

pro.appendChild(proInner);

var text = document.createElement("div");

text.style.position = "absolute";

text.style.left = "50px";

text.style.top = "2px";

text.style.fontSize= "11px";

text.style.width = "40px";

text.style.height = "16px";

text.style.zIndex = "103";

div.appendChild(text);

}

function xySetProgressTop(pStyleTop){

try{

var e = document.all(this.xyProgressID);

e.style.top = pStyleTop;

}catch(e){

alert(e.description);

}

}

function xySetProgressLeft(pStyleLeft){

try{

var e = document.all(this.xyProgressID);

e.style.left = pStyleLeft;

}catch(e){

alert(e.description);

}

}

function xySetProgressWidth(pWidth){

try{

var e = document.all(this.xyProgressID);

e.style.width = pWidth;

eOuter = e.children(0);

eOuter.style.width = pWidth;

this.width = pWidth;

}catch(e){

alert(e.description);

}

}

function xySetProgressHeight(pHeight){

try{

var e = document.all(this.xyProgressID);

e.style.height = pHeight;

eOuter = e.children(0);

eInner = e.children(0).children(0);

eOuter.style.height = pHeight;

eInner.style.height = pHeight-4;

this.height = pHeight;

}catch(e){

alert(e.description);

}

}

function xySetProgressBorderColor(pColor){

try{

var e = document.all(this.xyProgressID);

e = e.children(0);

e.style.border = "1px solid "+pColor;

}catch(e){

alert(e.description);

}

}

function xySetProgressForeBorderColor(pColor){

try{

var e = document.all(this.xyProgressID);

e = e.children(0).children(0);

e.style.border = "1px solid "+pColor;

}catch(e){

alert(e.description);

}

}

function xySetProgressBackColor(pColor){

try{

var e = document.all(this.xyProgressID);

e = e.children(0);

e.style.background = pColor;

}catch(e){

alert(e.description);

}

}

function xySetProgressForeColor(pColor){

try{

var e = document.all(this.xyProgressID);

e = e.children(0).children(0);

e.style.background = pColor;

}catch(e){

alert(e.description);

}

}

function xyEnableProgressText(bEnable){

try{

var e = document.all(this.xyProgressID);

eText = e.children(1);

if(bEnable){

eText.style.display = "none";

}else{

eText.style.display = "";

}

var pos = e.style.width;

var sel = eText.style.width;

pos = (pos-sel)/2;

eText.style.left = pos;

}catch(e){

alert(e.description);

}

}

function xySetProgressTextFontSize(pSize){

try{

var e = document.all(this.xyProgressID);

e = e.children(1);

e.style.fontSize = pSize;

}catch(e){

alert(e.description);

}

}

function xySetProgressTextFontColor(pColor){

try{

var e = document.all(this.xyProgressID);

e = e.children(1);

e.style.fontColor = pColor;

}catch(e){

alert(e.description);

}

}

function xySetProgressTextFontFamily(pFamily){

try{

var e = document.all(this.xyProgressID);

e = e.children(1);

e.style.fontFamily = pFamily;

}catch(e){

alert(e.description);

}

}

function xySetProgressMax(pMax){

this.max = pMax;

}

function xySetProgressMin(pMin){

this.min = pMin;

}

function xyUpdatePosition(pPosition){ /*将progress增长或减小pPosition,其中,0<pPersent<max*/

try{

var max = this.max;

var min = this.min;

var e = document.all(this.xyProgressID);

if(pPosition>max){

return -1;

}

var len = this.width;

var pos = this.currPos+(pPosition/(max-min))*len;

eProgress = e.children(0).children(0);

if(pos>=this.width){

eProgress.style.width = this.width-4;

this.currPos = pos;

}else if(pos<=0){

eProgress.style.width = 0;

this.currPos = pos;

}else{

eProgress.style.width = pos;

this.currPos = pos;

}

return this.currPos;

}catch(e){

alert(e.description);

return -1;

}

}

function xyUpdateToPosition(pPosition){ /*将progress更新到pPosition位置,其中,min<pPersent<max*/

try{

var max = this.max;

var min = this.min;

var e = document.all(this.xyProgressID);

if(pPosition<min||pPosition>max){

return -1;

}

var len = this.width;

var pos = ((pPosition-min)/(max-min))*len;

eProgress = e.children(0).children(0);

if(pos>=this.width){

eProgress.style.width = this.width-4;

this.currPos = pos;

}else if(pos<=0){

eProgress.style.width = 0;

this.currPos = pos;

}else{

eProgress.style.width = pos;

this.currPos = pos;

}

return this.currPos;

}catch(e){

alert(e.description);

return -1;

}

}

function xyUpdatePersent(pPersent){ /*从当前位置增长或减小pPersent%,pPersent大于零:增长,否则,减小*/

try{

var e = document.all(this.xyProgressID);

e = e.children(0).children(0);

var len = this.width;

var pos = this.currPos;

len = len*pPersent/100;

pos += len;

if(pos>this.width||pos<0){

return -1;

}

e.style.width = pos;

this.currPos = pos;

return this.currPos;

}catch(e){

alert(e.description);

return -1;

}

}

function xyUpdateToPersent(pPersent){ /*从当前位置增长或减小到pPersent%*/

try{

var e = document.all(this.xyProgressID);

e = e.children(0).children(0);

var len = this.width;

var pos = len*pPersent/100;

if(pos>this.width||pos<0){

return -1;

}

e.style.width = pos;

this.currPos = pos;

return this.currPos;

}catch(e){

alert(e.description);

return -1;

}

}

function xyNewID(){

var d = new Date();

var t = "oDraw_"+d.getTime().toString();

return t;

}

</script>

</HEAD>

<body topmargin=0 id="bodyID">

<script>

var xy = new xyProgressLG("kitty");

xy.SetProgressLeft(200)

xy.SetProgressTop(200);

xy.SetProgressWidth(200)

xy.SetProgressHeight(20)

xy.SetProgressMax(200)

xy.SetProgressMin(50);

</script>

<Script LANGUAGE="JavaScript">

function update(){

xy.UpdatePosition(10)

setTimeout("update()",100);

}

</Script>

<button onclick="xy.UpdateToPersent(20)">update</button>

<button onclick="xy.UpdatePosition(10)">updatePosition</button>

<button onclick="update()">autoUpdate</button>

</BODY>

</HTML>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有