Maison  >  Article  >  interface Web  >  js 蒙版进度条(结合图片)_javascript技巧

js 蒙版进度条(结合图片)_javascript技巧

WBOY
WBOYoriginal
2016-05-16 18:32:401126parcourir
复制代码 代码如下:

/********************
** js 蒙版进度条(图片)
** dingzh@jstrd.com
** 2009-12-03
*********************/

//禁止网页后退
window.history.forward(1);
document.attachEvent("onkeydown",docKeyDown);
function docKeyDown() {
//屏蔽退格删除键
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;
}
}
}


//加载进度条
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() {
//是否正在提交
if(!process_submit_doing) {
return;
}
//
var showProcess = false;
//捕获事件源
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("提交", "确定", "保存", "暂存", "结账", "审核", "审批", "作废", "回退", "退回", "驳回",
"退单", "撤消", "导入", "受理", "办理", "处理", "查询", "入库", "入账", "出库", "出账");

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

//alert(showProcess);
//不显示进度条
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;
}
}

//页面蒙版
function createProcessBgDiv()
{
var h=document.body.scrollHeight;
var w=document.body.scrollWidth;
var div=document.createElement("
");
//div.appendChild(document.createTextNode("xxxxxxxxxxxxxxxxxxxx"));
div.appendChild(document.createElement(""));
document.body.appendChild(div);
document.body.appendChild(document.createElement("
"));

//屏蔽鼠标右键
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
}
/*function delProcessBgDiv()
{
document.body.removeChild(document.getElementById("divProcessBg"));
document.onmousedown = null;
} */
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn