zoukankan      html  css  js  c++  java
  • 【整理】Web页面防止重复提交

    var isIe=(document.all)?true:false;
    //设置select的可见状态
    function setSelectState(state)
    {
    var objl=document.getElementsByTagName('select');
    for(var i=0;i<objl.length;i++){
    objl[i].style.visibility
    =state;
    }
    }
    function mousePosition(ev)
    {
    if(ev.pageX || ev.pageY){
    return {x:ev.pageX, y:ev.pageY};
    }
    return{
    x:ev.clientX
    + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop
    };
    }
    //弹出方法
    function showMessageBox(ev,wTitle,content,wWidth,isShowClose)
    {
    if( confirm('Confirm to Continue (确认此操作)?') )
    {
    var pos = mousePosition(ev);
    closeWindow();
    var bWidth=parseInt(document.documentElement.scrollWidth);
    var bHeight=parseInt(document.documentElement.scrollHeight);
    if(isIe){
    setSelectState(
    'hidden');
    }
    var back=document.createElement("div");
    back.id
    ="back";
    var styleStr="top:0px;left:0px;position:absolute;background:#666;"+bWidth+"px;height:"+bHeight+"px;";
    styleStr
    +=(isIe)?"filter:alpha(opacity=30);":"opacity:30;";
    back.style.cssText
    =styleStr;
    document.body.appendChild(back);
    showBackground(back,
    50);
    var mesW=document.createElement("div");
    mesW.id
    ="mesWindow";

    var html = "<div style='border-bottom: #eee 1px solid;margin-left: 4px;padding: 3px;font-weight: bold;text-align: left;font-size: 12px;'>";
    html
    += "<table width='100%' height='100%'><tr><td>"+wTitle+"</td><td style='1px;'>";
    if( isShowClose == 1 )
    {
    html
    += "<input type='button' onclick='closeWindow();' title='Close(关闭窗口)' style='height: 15px; 28px;border: none;cursor: pointer;text-decoration: underline;background: #fff;' value='关闭' />";
    }
    html
    += "</td></tr></table></div><div style='margin: 4px;font-size: 12px;padding:20px 0 20px 0;text-align:center' id='mesWindowContent'>"+content+"</div>";
    mesW.innerHTML
    = html ;
    var v_top=(document.body.clientHeight-mesW.clientHeight)/3;
    v_top+=document.documentElement.scrollTop;

    styleStr
    ="border:#666 1px solid;background:#fff;top:"+v_top+"px;left:"+(document.body.clientWidth/2-mesW.clientWidth/2)+"px;position:absolute;600px;margin-left:-300px;left:50%;z-index:9999;";
    mesW.style.cssText
    = styleStr;

    document.body.appendChild(mesW);
    return true;
    }
    else
    return false;
    }
    //让背景渐渐变暗
    function showBackground(obj,endInt)
    {
    if(isIe){
    obj.filters.alpha.opacity
    +=5;
    if(obj.filters.alpha.opacity<endInt){
    setTimeout(
    function(){showBackground(obj,endInt)},1);
    }
    }
    else{
    var al=parseFloat(obj.style.opacity);al+=0.05;
    obj.style.opacity
    =al;
    if(al<(endInt/100)){
    setTimeout(function(){showBackground(obj,endInt)},1);
    }
    }
    }
    //关闭窗口
    function closeWindow()
    {
    if(document.getElementById('back')!=null){
    document.getElementById(
    'back').parentNode.removeChild(document.getElementById('back'));
    }
    if(document.getElementById('mesWindow')!=null){
    document.getElementById(
    'mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
    }
    if(isIe){
    setSelectState(
    '');
    }
    }

    function showMessageBox_sample(ev)
    {
    return showMessageBox(ev,'友情提醒','Wating........(数据提交中,请耐心等待)',350,0);
    }

    使用:btnSubmit.Attributes.Add("onclick", "return showMessageBox_sample(event);")

  • 相关阅读:
    HDU2149-Public Sale
    分页和多条件查询功能
    hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq
    BZOJ 2588 Count on a tree (COT) 是持久的段树
    windows 设置脚本IP
    hdu 4912 Paths on the tree(树链拆分+贪婪)
    分散式-ubuntu12.04安装hadoop1.2.1
    struts详细解释拦截器
    Codeforces 459E Pashmak and Graph(dp+贪婪)
    C#中的数据格式转换 (未完待更新)
  • 原文地址:https://www.cnblogs.com/wonder315/p/1956236.html
Copyright © 2011-2022 走看看