让提交按钮返回后自动可用

<input type="button" name="exportBtn" id="exportBtnId" value="导出Excel" class="button"
      οnclick="searchViewFixCardForBrushListForm.submit();this.blur();"/>

 

<script type="text/javascript">

function RestEnableButton(obj){ 
 this.btnObj = (typeof obj=="string")?document.getElementById(obj):obj;
 if(window.document.readyState=='complete'){
  btnObj.disabled='';
  endRequestLoading();
 }else{
  setTimeout('RestEnableButton(\''+obj+'\')',1000);
 }
}

function RequestEndEnableBtn(obj){
    var me = this;
    this.foo = (typeof obj=="string")?document.getElementById(obj):obj;
    this.foo.onblur = function(){
         var foo = me.foo;
         foo.disabled = 'disabled';
         startRequestLoading();
         setTimeout('RestEnableButton(\''+obj+'\')',1000);
    }
}

 

new RequestEndEnableBtn('exportBtnId');

</script>

 

-------------------------------------改进-----------------------------------------

function RequestEnableButton(obj){ 
 this.btnObj = (typeof obj=="string")?document.getElementById(obj):obj;
 if(window.document.readyState=='complete'){
  btnObj.disabled='';
  endRequestLoading();
 }else{
  setTimeout('RequestEnableButton(\''+obj+'\')',1000);
 }
}

function RequestEndEnableBtn(obj){
    var me = this;
    this.foo = (typeof obj=="string")?document.getElementById(obj):obj;
    var orgFun = this.foo.onclick;
    this.foo.onclick = function(){
      var foo = me.foo;
        new orgFun();
        foo.disabled = 'disabled';
        startRequestLoading();
        setTimeout('RequestEnableButton(\''+obj+'\')',1000);
    }
}

 

------------------------------------------  改进  ----------------------------------------- 

<input type="button" name="exportstaticsBtn" value="导出Excel" class="button" οnmοuseοver="new EnableBtnOnCompleteObj(this);" οnclick="searchViewPowerCardForBrushListForm.action='form.submit();"/>

 

//让按钮点击后不可用disabled,请求返回后自动可用; 在需用的按钮添加 οnmοuseοver="new EnableBtnOnCompleteObj(this);"


function EnableBtnOnCompleteObj(obj){
 var me = this;
    this.foo = (typeof obj=="string")?document.getElementById(obj):obj;
    var orgFun = this.foo.onclick;       //取得并保存原来的onclick函数到orgFun
    if(obj.flag==undefined || obj.flag==false){
     this.foo.onclick = function(){
       var foo = me.foo;
         new orgFun();        //加载原来的onclick函数
         foo.disabled = 'disabled';
         startRequestLoading();
         setTimeout(EnableBtnOnComplete,1000);
     }
     obj.flag = true;
    }

 function EnableBtnOnComplete(){ 
  this.foo = me.foo;
  if(window.document.readyState=='complete'){
   foo.disabled='';
   endRequestLoading();
  }else{
   setTimeout(EnableBtnOnComplete,1000);
  }
 }
}

 

--------------------------------- 改进 ----------------------------------------------

//让按钮点击后不可用disabled,请求返回后自动可用; 在需用的按钮添加 οnmοuseοver="new EnableBtnOnCompleteObj(this);"
function EnableBtnOnCompleteObj(obj){
 var me = this;
    this.foo = (typeof obj=="string")?document.getElementById(obj):obj;
    var orgFun = this.foo.onclick;
    if(obj.flag==undefined || obj.flag==false){
     this.foo.onclick = function(){
       var foo = me.foo;
         new orgFun();
         foo.disabled = 'disabled';
         startRequestLoading();
         setTimeout(EnableBtnOnComplete,1000);
     }
     obj.flag = true;
    }

 function EnableBtnOnComplete(){ 
  this.foo = me.foo;
  if(window.document.readyState=='complete'){
   foo.disabled='';
   endRequestLoading();
  }else{
   setTimeout(EnableBtnOnComplete,1000);
  }
 }
}

 

//添加了这些代码,在需要用到的按钮上只要添加一个属性 enableOnComplete="true" 即可

window.document.οnmοusedοwn=function(e){
 e = e||event;
 var el = e.srcElement || e.target;
 if(el.flag!=null) return;
 var eTag = el.tagName;
    var eType = el.getAttribute('type') || '';
    if((el.tagName=='INPUT' && eType.toUpperCase()=='BUTTON') || eTag=='BUTTON'){
     if(el.getAttribute('enableOnComplete')!='' && el.getAttribute('enableOnComplete')=='true'){
      new EnableBtnOnCompleteObj(el);
     }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值