当前位置: 代码迷 >> Web前端 >> 重复提交 禁止接续点击同一链接
  详细解决方案

重复提交 禁止接续点击同一链接

热度:77   发布时间:2012-11-22 00:16:41.0
重复提交 禁止连续点击同一链接
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>测试</title>
</head>
<script language="javascript">
var t = null;
var flag = true;
function check(obj) {
	if (flag) {
		obj.disabled = flag;
		flag = false;
		t = setTimeout(function(){disable(obj)}, 5000); // 5秒间隔
		window.open("http://www.baidu.com", "newWindow");
	}
}

function disable(obj) {
	obj.disabled = flag;
	flag = true;
	if (t != null)
	clearTimeout(t);
}
</script>
<body>
<a href="#" onclick="check(this)">ceshi1</a>
</body>
</html>

?<a href= "http://www.google.com " onclick= "window.open(this.href);document.getElementsByTagName('a')[0].href = 'javascript:void(0)';"> 链接1 </a>

链接disabled =true只显示禁用的效果,但任然可以点<a href="http://www.google.cn" onclick="var that = this; setTimeout(function(){that.href = '###'; that.target=''; that.onclick=function(){ return false; }; });" target="_blank">Open Google in New Window</a>

  相关解决方案