今天写了个防止按钮的二次点击的js
var disabledelem;
function clickBtn(e) {
try {
var e;
var elem = null;
e = e ? e : (window.event ? window.event : null);
if (e) {
elem = e.target ? (e.target.nodeType == 3 ? e.target.parentNode : e.target) : e.srcElement;
}
//for(e in elem) alert(e);
if (elem != null && elem.type != null) {
if (elem.type == "submit") {
if (!elem.isDisabled) {
disabledelem = elem;
elem.disabled = true;
document.forms[0].submit();
}
} else {
if (elem.type == "button") {
if (!elem.isDisabled) {
disabledelem = elem;
elem.disabled = true;
}
} else {
if (disabledelem != null) {
disabledelem.disabled = false;
}
}
}
} else {
if (disabledelem != null) {
disabledelem.disabled = false;
}
}
}
catch (e) {
alert("error" + e.message + "has" + e.lineNumber + "line");
}
}
document.onclick = clickBtn;
var disabledelem;
function clickBtn(e) {
try {
var e;
var elem = null;
e = e ? e : (window.event ? window.event : null);
if (e) {
elem = e.target ? (e.target.nodeType == 3 ? e.target.parentNode : e.target) : e.srcElement;
}
//for(e in elem) alert(e);
if (elem != null && elem.type != null) {
if (elem.type == "submit") {
if (!elem.isDisabled) {
disabledelem = elem;
elem.disabled = true;
document.forms[0].submit();
}
} else {
if (elem.type == "button") {
if (!elem.isDisabled) {
disabledelem = elem;
elem.disabled = true;
}
} else {
if (disabledelem != null) {
disabledelem.disabled = false;
}
}
}
} else {
if (disabledelem != null) {
disabledelem.disabled = false;
}
}
}
catch (e) {
alert("error" + e.message + "has" + e.lineNumber + "line");
}
}
document.onclick = clickBtn;