javascript控制页面表单重复提交
// PageLoad事件
var onloadMethod = window.onload;
window.onload = window_Load;
function window_Load() {
var i;
var item;
// 全部连接的事件
for (i = 0; i < document.links.length; i ++) {
item = document.links[i]
Object.Aspect.around(item, "onclick", checkLoading);
}
// 全部按钮的事件
for (i = 0; i < document.forms[0].elements.length; i ++) {
item = document.forms[0].elements[i]
if (item.type == "button" ||
item.type == "submit" ||
item.type == "reset") {
Object.Aspect.around(item, "onclick", checkLoading);
}
}
if (onloadMethod != null && typeof (onloadMethod) == "function") {
// 执行Page的onload事件
return onloadMethod();
} else {
return true;
}
}
// 防止重复提交
var checkLoading = function(invocation) {
if (isDocumentLoading()) {
//alert("now loading…");
return false;
}
return invocation.proceed();
}
// 当前页面提交状态判断
function isDocumentLoading() {
return (document.readyState != null &&
document.readyState != "complete" &&
document.readyState != "interactive");
}
// Aspect 用
Object.Aspect = {
_around: function(target, methodName, aspect) {
var method = target[methodName];
target[methodName] = function() {
var invocation = {
"target" : this,
"method" : method,
"methodName" : methodName,
"arguments" : arguments,
"proceed" : function() {
if (!method) {
return true;
}
return method.apply(target, this.arguments);
}
};
return aspect.apply(null, [invocation]);
};
},
around: function(target, methodName, aspect) {
this._around(target, methodName, aspect);
}
}
相关文档:
Javascript 在ASP.net 母板页下访问 控件ID:
对于 html control : 直接访问ID
document.getElementById("hfRespondID");
对于 Web control :
document.getElementById("<%= this.hfRespondID.ClientID %>") [注意大小写
]
&nb ......
<html>
<head>
<mce:script type="text/javascript"><!--
function aaa()
{
alert("oh no");
window.location="http://community.csdn.net/";
}
// --></mce:script>
</head>
<body onload = aaa();>
< ......
引子
编程世界里只存在两种基本元素,一个是数据,一个是代码。编程世界就是在数据和代码千丝万缕的纠缠中呈现出无限的生机和活力。
数据天生就是文静的,总想保持自己固有的本色;而代码却天生活泼,总想改变这个世界。
你看,数据代码间的关系与物 ......
字母和数字键的键码值(keyCode)
按键
键码
按键
键码
按键
键码
按键
键码
A
65
J
74
S
83
1
49
B
66
K
75
T
84
2
50
C
67
L
76
U
85
3
51
D
68
M
77
V
86
4
52
E
69
N
78
W
87
5
53
F
70
O
79
X
88
6
54
G
71
P
80
Y
89
7
55
H
72
Q
81
Z
90
8
......
//过滤所有的非中文,字母,数字字符
function filter_str(str)
{
interval=typeof(arguments[1])!='undefined'?arguments[1]:' ';
if(str.length>0)str=DBC2SBC(str)
return str.replace(/[^\u4E00-\u9FA5a-zA-Z0-9]/g,in ......