Home > Web Front-end > JS Tutorial > js mask progress bar (combined with pictures)_javascript skills

js mask progress bar (combined with pictures)_javascript skills

WBOY
Release: 2016-05-16 18:32:40
Original
1150 people have browsed it
Copy code The code is as follows:

/********************
** js mask progress bar (picture)
** dingzh@jstrd.com
** 2009-12- 03
*************************/

/ /Disable webpage back
window.history.forward(1);
document.attachEvent("onkeydown",docKeyDown);
function docKeyDown() {
//Shield the backspace delete key
if (window.event.keyCode == 8) {
if(window.event.srcElement.type != "text"
&& window.event.srcElement.type != "textarea"
&& window.event.srcElement.type != "password") {
window.event.keyCode = 0x0;
return false;
} else if(window.event.srcElement.readOnly) {
window.event.keyCode = 0x0;
return false;
}
}
}


//Loading progress bar
var process_submit_doing = false;
try {
window.attachEvent("onload",doBodyLoad);
//document.attachEvent("onclick",doProcess);
window.attachEvent("onbeforeunload",doWinLoad);
} catch(e) {
document.addEventListener("onclick",doProcess,false);
window.addEventListener("onbeforeunload",doWinLoad,false);
}
//
function doBodyLoad() {
var obj;
var vInput=document.getElementsByTagName("INPUT");
for(var i in vInput) {
obj=vInput[i];
if(obj.type=="button" || obj.type=="submit") {
obj.attachEvent("onclick",doProcess);
}
}
vInput=document .getElementsByTagName("IMG");
for(var i in vInput) {
obj=vInput[i];
if(undefined != obj.alt) {
obj.attachEvent(" onclick",doProcess);
}
}
}
//
function doWinLoad() {
process_submit_doing = true;
}
//
function doProcess() {
//Whether it is being submitted
if(!process_submit_doing) {
return;
}
//
var showProcess = false;
//Capture Event source
var eventObj = event.srcElement;
var btnvalue = "";
if(eventObj.tagName=='INPUT') {
btnvalue = eventObj.value;
} else if(eventObj.tagName=='IMG') {
if(null != eventObj.alt && "" != eventObj.alt) {
btnvalue = eventObj.alt;
} else {
btnvalue = eventObj.title;
}
}
btnvalue = btnvalue.replace(/ */g,"").replace(/ */g,"");
//
var my_array = new Array();
my_array.unshift("Submit", "Confirm", "Save", "Temporary", "Checkout", "Review", "Approval", "Void", "Return", "Return", "Reject",
"Refund", "Cancel", "Import", "Accept", "Handle", "Process", "Query", "Storage", "Incoming account", "Outgoing account", "Outgoing account");

for (i = 0; i < my_array.length; i ) {
if(new RegExp(my_array[i], "ig").test(btnvalue)) {
showProcess = true;
break;
}
}

//alert(showProcess);
//No Show progress bar
if(!showProcess) {
return;
}
//
createProcessBgDiv();
}


function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick()
{
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}

//Page mask
function createProcessBgDiv()
{
var h=document.body.scrollHeight;
var w=document.body.scrollWidth;
var div=document .createElement("
");
//div.appendChild(document.createTextNode("xxxxxxxxxxxxxxxxxxxxxxxx"));
div.appendChild (document.createElement(""));
document.body.appendChild(div) ;
document.body.appendChild(document.createElement("
"));

//Shield the right mouse button
document.oncontextmenu = nocontextmenu; // for IE5
document.onmousedown = norightclick; // for all others
}
/*function delProcessBgDiv()
{
document.body.removeChild( document.getElementById("divProcessBg"));
document.onmousedown = null;
} */
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template