<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);
}
}
}