var dbNumForVehicle=0;
function clkForVehicle(cnum)
{
dbNumForVehicle=cnum;
if(dbNumForVehicle==1){
window.location.href='<portlet:actionURL>
<portlet:param name="cmd" value="rmVehicle"/>
<portlet:param name="vehicleId">
<jsp:attribute name="value">
${chgVehicle.vehicleId}
</jsp:attribute>
</portlet:param>
<portlet:param name="policyNumber">
<jsp:attribute name="value">
${policyNumber}
</jsp:attribute>
</portlet:param>
<portlet:param name="year">
<jsp:attribute name="value">
${chgVehicle.year}
</jsp:attribute>
</portlet:param>
<portlet:param name="make">
<jsp:attribute name="value">
${chgVehicle.make}
</jsp:attribute>
</portlet:param>
<portlet:param name="vmodel">
<jsp:attribute name="value">
${chgVehicle.model}
</jsp:attribute>
</portlet:param>
</portlet:actionURL>';
return true;
}
if(dbNumForVehicle==2){
alert("Don't double click, waiting!!!...");
return false; //do nothing.
}
} 我想在超链接里,控制它,不让它双击提交(第二次拒绝!)
<a href="#" ondblclick="return clkForVehicle(2);" onClick="return clkForVehicle(1);">
function clkForVehicle(cnum)
{
dbNumForVehicle=cnum;
if(dbNumForVehicle==1){
window.location.href='<portlet:actionURL>
<portlet:param name="cmd" value="rmVehicle"/>
<portlet:param name="vehicleId">
<jsp:attribute name="value">
${chgVehicle.vehicleId}
</jsp:attribute>
</portlet:param>
<portlet:param name="policyNumber">
<jsp:attribute name="value">
${policyNumber}
</jsp:attribute>
</portlet:param>
<portlet:param name="year">
<jsp:attribute name="value">
${chgVehicle.year}
</jsp:attribute>
</portlet:param>
<portlet:param name="make">
<jsp:attribute name="value">
${chgVehicle.make}
</jsp:attribute>
</portlet:param>
<portlet:param name="vmodel">
<jsp:attribute name="value">
${chgVehicle.model}
</jsp:attribute>
</portlet:param>
</portlet:actionURL>';
return true;
}
if(dbNumForVehicle==2){
alert("Don't double click, waiting!!!...");
return false; //do nothing.
}
} 我想在超链接里,控制它,不让它双击提交(第二次拒绝!)
<a href="#" ondblclick="return clkForVehicle(2);" onClick="return clkForVehicle(1);">
帮你改了下 试试吧var count = 0;//定义全局变量
var timer;
function clickHandler()
{
count ++;
timer = window.setTimeout(function(){
if(count==1) {
clkForVehicle(1);//调用单击处理函数
}
else {
clkForVehicle(2)//调用双击处理函数
}
window.clearTimeout(timer)
count=0
},500)
} <a href="#" onmouseup="clickHandler()"></a>
不可行,不可以简单的return false;to 3楼的朋友, 超链接你是没有办法disable的,只能隐藏,隐藏的话也不可行。页面就少了元素了。
to 2楼的朋友,你的这个方法,好像不可行,页面的其他js效果都没有了。
当点击这个事件的时候修改这个标签的修改这个class为clicked,然后click的事件执行完后把class改成unclicked。然后在里面通过class的判断来阻止A标签激发2次