html5进度条插件 传递参数,Html5进度条插件(自写)

(function () {

window.H5ProgressBar = function (obj) {

this.height = obj.height;

this.width = obj.width;

this.speed = obj.speed;

};

//在界面上布局元素

H5ProgressBar.prototype.drawLayout = function () {

document.write("

开始下载

")

document.write(" ")

document.write("下载
")

document.write("
")

document.write("设置宽度:确定
")

document.write("设置高度:确定
")

document.write("设置速度:确定
")

}

//初始化方法,即程序入口,一开始从这里执行

H5ProgressBar.prototype.init = function () {

this.drawLayout();

var objPro = document.getElementById('proDownFile');

var width = this.width + "px"

var height = this.height + "px"

objPro.style.width = width;

objPro.style.height = height;

this.setProgressWidth();

this.setProgressHeight();

this.load();

this.setLoadSpeed();

}

//设置进度条的宽度

H5ProgressBar.prototype.setProgressWidth = function () {

var setWidthBtn = document.getElementById('setWidthBtn');

setWidthBtn.addEventListener('click', function () {

var progress = document.getElementById('proDownFile');

var width = document.getElementById('width');

var newWidth = width.value

if (newWidth.length == 0) {

alert("不能为空");

} else {

if (!isNaN(newWidth)) {

progress.style.width = newWidth + "px"

}

else {

alert("请输入数字类型")

}

}

});

}

//设置进度条的高度

H5ProgressBar.prototype.setProgressHeight = function () {

var setHeightBtn = document.getElementById('setHeightBtn');

setHeightBtn.addEventListener('click', function () {

var progress = document.getElementById('proDownFile');

var height = document.getElementById('height');

var newHeight = height.value

if (newHeight.length == 0) {

alert("不能为空");

} else {

if (!isNaN(newHeight)) {

progress.style.height = newHeight + "px"

}

else {

alert("请输入数字类型")

}

}

});

}

var intValue = 0;

var intTimer;

var objTip;

//下载

H5ProgressBar.prototype.load = function () {

var load = document.getElementById('load');

var time = 1000 - this.speed * 10;

load.addEventListener('click', function () {

Btn_Click(time);

});

}

//设置下载速度

H5ProgressBar.prototype.setLoadSpeed = function () {

var speed = document.getElementById('setSpeedBtn');

speed.addEventListener('click', function () {

var speed = document.getElementById('speed');

var newSpeed = speed.value

if (newSpeed.length == 0) {

alert("不能为空");

}

else {

if (!isNaN(newSpeed)) {

if (newSpeed <= 0 || newSpeed > 100) {

alert("请设置1-100%之内的数")

} else {

Btn_Click(1000 - newSpeed * 10);

}

}

else {

alert("请输入数字类型")

}

}

})

}

//设置时间

function Btn_Click(time) {

var progress = document.getElementById('proDownFile');

intValue = progress.value

if (intValue == progress.max) {

reset()

}

else {

intTimer = setInterval(Interval_handler, time);

}

}

//重新下载

function reset() {

intValue = 0;

var progress = document.getElementById('proDownFile');

intTimer = setInterval(Interval_handler, 1000);

}

//定时事件

function Interval_handler() {

intValue++;

var objPro = document.getElementById('proDownFile');

objTip = document.getElementById('loadTip');

objPro.value = intValue;

if (intValue >= objPro.max) {

clearInterval(intTimer);

objTip.innerHTML = "下载完成";

} else {

intValue += Math.random() * 1.8;

intValue = parseFloat(intValue.toFixed(1));

objTip.innerHTML = "正在下载" + intValue + "%";

}

}

})();

0818b9ca8b590ca3270a3433284dd417.png

用法:

new H5ProgressBar({

height:20,

width:500,

speed:10

}).init();

0818b9ca8b590ca3270a3433284dd417.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/394630.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python合并txt文本_Python实现将目录中TXT合并成一个大TXT文件的方法

本文实例讲述了Python实现将目录中TXT合并成一个大TXT文件的方法。分享给大家供大家参考。具体如下&#xff1a; 在网上下了一个dota的英雄攻略,TXT格式,每个英雄一个文件,看得疼,就写了一个小东西,合并一下. #codinggbk import os import sys import glob def dirTxtToLargeTx…

读取字符串中的数字和小数

package com.jm.label.tools;import java.util.Map;import java.util.TreeMap;import java.util.regex.Matcher;import java.util.regex.Pattern;/** * 读取字符串中的数字和小数 * author JM.H * */public class DigitUtil { public static String getNumber(String str){ …

html网页设计要点,网站交互设计的8个要点

一、力求一致性例如网站首页需要和每一个下级页面保持一致的风格&#xff0c;导航都要放在屏幕的左上角&#xff0c;具有高度一致性的界面能给人清晰整洁的感觉。二、允许频繁使用快捷键快捷键表示产品使用的灵活性和有效性&#xff0c;想想每次我们使用搜索引擎的时候是鼠标点…

行为扩展以及插件机制

在thinkPHP中的行为扩展和插件机制。 首先行为扩展这个概念是TP框架的核心组成之一&#xff0c;关于行为的解释我就粗略的概括一下吧&#xff1a; TP在从接受到HTTP请求到最终将试图输出&#xff0c;期间经历的很多步骤&#xff0c;这些步骤大家可以在http://document.thinkphp…

python android 库_Python库

Gevent Gevent是一个基于greenlet的Python的并发框架&#xff0c;以微线程greenlet为核心&#xff0c;使用了epoll事件监听机制以及诸多其他优化而变得高效。 于greenlet、eventlet相比&#xff0c;性能略低&#xff0c;但是它封装的API非常完善&#xff0c;最赞的是提供了一个…

ios 应用商店_如何在预算范围内制作值得应用商店使用的iOS应用预览

ios 应用商店Back in 2014, Apple made it possible to add an app preview to the the App Store. App previews are the best way to show potential users what your app has to offer before they download the app. In fact, users are 3x more likely to install an app …

搭建nfs共享存储服务之二nfs服务端配置

1.1.NFS服务端配置文件路径为&#xff1a; /etc/exports&#xff0c;并且默认为空&#xff0c;需要用户自行配置。/etc/exports文件配置格式为&#xff1a;NFS共享的目录 NFS客户端地址1&#xff08;参数1&#xff0c;参数2...&#xff09;客户端地址2&#xff08;参数1&#x…

计算机word基本知识选择题,2017计算机基础考试选择题「附答案」

2017计算机基础考试选择题「附答案」一、单项选择题(每题1.5分&#xff0c;共30分)1、文件名使用通配符的作用是(b)A、减少文件名所占用的磁盘空间B、便于一次处理多个文件C、便于给一个文件命名D、便于保存文件2、操作系统是一种(a)A、系统软件 B、系统程序库 C、编译程序系统…

[JLOI2015]管道连接(斯坦纳树)

[Luogu3264] 原题解 多个频道,每个频道的关键点要求相互联通 详见代码,非常巧妙 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<queue> #define debug(...) fprintf(stderr,__VA_ARGS__) #define Debug(…

关于web前端的学习路线

第一阶段&#xff1a; HTMLCSS:HTML进阶、CSS进阶、divcss布局、HTMLcss整站开发、 JavaScript基础&#xff1a;Js基础教程、js内置对象常用方法、常见DOM树操作大全、ECMAscript、DOM、BOM、定时器和焦点图。 JS基本特效&#xff1a;常见特效、例如&#xff1a;tab、导航、整页…

值大于为此列指定的允许精度_电能质量测试精度会受到哪些因素影响?如何解决?...

关于电能质量&#xff08;也称为PQ:Power Quality&#xff09;研究的主题已成为多方面的话题。其需要考虑的不仅仅是IEC 61000-x-x电磁兼容性标准中规定的实际电能质量现象。在实践中&#xff0c;通常还会增加其他重要参数来保证供电的安全性&#xff0c;在某些情况下这些参数甚…

SEO博客

http://www.chinamyhosting.com/seoblog/分类: SEO 本文转自快乐就好博客园博客&#xff0c;原文链接&#xff1a;http://www.cnblogs.com/happyday56/archive/2008/05/10/1191435.html&#xff0c;如需转载请自行联系原作者

gis计算各省河流长度_用河流和各方解释安全漏洞

gis计算各省河流长度by Andrea Zanin由Andrea Zanin 用河流和各方解释安全漏洞 (Security Vulnerabilities Explained with Rivers and Parties) Security vulnerabilities can be boring to learn. But you still need to learn them, unless you want some hacker to delete…

Delphi关于记录文件的操作

http://www.cnblogs.com/railgunman/archive/2010/08/16/1801004.html Delphi关于记录文件的操作 本例子几个变量的说明TFileRec record   //记录定义Day : Integer;...          //其他定义end;f : File of TFileRec;   //标准的输入/输出文件FilRec : TFileR…

pygame游戏开发入门例子

# *_* coding:utf-8 *_*# 开发团队:中国软件开发团队# 开发人员:Administrator# 开发时间:2019/3/23 11:16# 文件名称:pygame_demo# 开发工具:PyCharmimport sysimport pygameimport timedef main(): sizewidth,height640,480 pygame.init() screenpygame.display.set…

HTML引入媒体查询CSS,CSS3 多媒体查询

CSS3 多媒体查询CSS2 多媒体类型media 规则在 CSS2 中有介绍&#xff0c;针对不同媒体类型可以定制不同的样式规则。例如&#xff1a;你可以针对不同的媒体类型(包括显示器、便携设备、电视机&#xff0c;等等)设置不同的样式规则。但是这些多媒体类型在很多设备上支持还不够友…

Codeforces 835 F Roads in the Kingdom(树形dp)

F. Roads in the Kingdom(树形dp) 题意&#xff1a; 给一张n个点n条边的无向带权图 定义不便利度为所有点对最短距离中的最大值 求出删一条边之后&#xff0c;保证图还连通时不便利度的最小值 $n < 2e5 $\(w_i < 1e9\) 思路:树形dp 这个图是一个环上挂着很多颗树&#xf…

前端websocket获取数据后需要存本地吗_是什么让我放弃了restful api?了解清楚后我全面拥抱GraphQL...

GraphQL初步认识背景REST作为一种现代网络应用非常流行的软件架构风格&#xff0c;自从Roy Fielding博士在2000年他的博士论文中提出来到现在已经有了20年的历史。它的简单易用性&#xff0c;可扩展性&#xff0c;伸缩性受到广大Web开发者的喜爱。REST 的 API 配合JSON格式的数…

列出薪金高于在部门30_我如何在五个月内将薪金提高一倍并获得一份了不起的工作...

列出薪金高于在部门30by Sam Williams通过山姆威廉姆斯 我如何在五个月内将薪金提高一倍并获得一份了不起的工作 (How I Doubled my Salary in Five Months and Got an Amazing Job) Six months ago I quit my job as a junior JavaScript developer and travelled around sou…

ftp服务器 vsftpd搭建和配置以及虚拟用户的设置

tp: File Transfer Protocol应用层协议&#xff1a;tcp, 21/tcpC/S&#xff1a;Client: 程序Server: 程序数据&#xff1a;命令连接&#xff1a;文件管理类命令&#xff0c;始终在线的连接数据连接&#xff1a;数据传输&#xff0c;按需创建及关闭的连接数据传输格式&#xff1…