您的位置:首页 > 编程语言 > ASP

ASP.NET的防止重复提交的脚本

2004-10-10 09:04 561 查看
function _doPostBack(){};
if(typeof("__doPostBack")=="function")
{
_doPostBack=__doPostBack;
__doPostBack=_doPostBackNew;
}

document.attachEvent("onmousemove",_onmousemove);
var _isPosting=false;
var _divMask=null;

function _onmousemove()
{
if(_divMask)
with(_divMask.runtimeStyle)
{
left=event.clientX+document.body.scrollLeft-4;
top=event.clientY+document.body.scrollTop-4;
}
}

function _makeMask()
{
var div=document.createElement("DIV");
with(div.runtimeStyle)
{
position="absolute";
zIndex=999999;
fontSize="1px";
left=event.clientX+document.body.scrollLeft-4;
top=event.clientY+document.body.scrollTop-4;
width="8px";
height="8px";
cursor="wait";

backgroundColor="gray";
filter="alpha(opacity=10)";
}
try
{
document.body.insertAdjacentElement("BeforeEnd",div);
div.onblur=new Function("this.focus()");
div.focus();
}
catch(x){}

if(_divMask)_divMask.removeNode(true);
_divMask=div;
}

function _doPostBackNew(sender,args)
{
if(_isPosting)
return event.returnValue=!(event.cancelBubble=true);

status="正在更新页面...";
_doPostBack(sender,args);
_isPosting=true;
_makeMask();
}

function _onformsubmit()
{
if(_isPosting)
return event.returnValue=!(event.cancelBubble=true);

_isPosting=true;
_makeMask();
}
new function _attachForms()
{
with(new Enumerator(document.forms))
for(;!atEnd();moveNext())
{
item().attachEvent("onsubmit",_onformsubmit);
var div=document.createElement("div");
div.runtimeStyle.width="0px";
div.runtimeStyle.hight="0px";
div.runtimeStyle.overflow="hidden";
div.runtimeStyle.position="absolute";
item(0).insertAdjacentElement("afterbegin",div);
div.innerHTML="<INPUT TYPE=Submit name='webformpatchsubmitelement' onclick='return event.returnValue=false' id='webformpatchsubmitelement' value='webformpatchsubmitelement'/>";
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: