解决方案 »

  1.   

    alert阻塞程序往下运行  貌似不能的样子
      

  2.   

    alert() 是不会自动关闭的,可以将alert()这个对话框换成窗口或是一个小的页面
      

  3.   

    我是通过后台拼接字符串显示,来显示的
    这样的话具体怎么去重写呢、。?//脚本块的内容
                strScript = "<script language=javascript>\n";
                strScript += string.Format("alert('{0}');\n", msg);
                strScript += "</script>";
      

  4.   

    自己写一个弹出层组件来作为消息框就行了思路是
    1.显示一个占据浏览器全部的层(一般设置为半透明)来遮住浏览器模拟模态效果
    2.再渲染一个比遮罩更高(z-index更大)的层来显示你的消息内容
      

  5.   

    window.alert = function(str) {
       //重寫alert
    }調用的時候就會調用這個你自定義的了
      

  6.   

    直接调用即可:for example :function showSimpleMessage() {
    // if ($("#simpaleMessageDiv").attr("id")=="")
    var flag = document.getElementById("simpaleMessageDiv")==null;
    if (flag) {
    $("BODY").append('<div id="simpaleMessageDiv" style="background-color:yellow">&nbsp;</div>');
    var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 

    $("#simpaleMessageDiv").css({
    position: pos,
    zIndex: 99999,
    padding: 0,
    margin: 0
    });

    $("#simpaleMessageDiv").text(arguments[0]);
    var top = 50;
    var left = (($(window).width() / 2) - ($("#simpaleMessageDiv").outerWidth() / 2)) + 0;
    if( top < 0 ) top = 0;
    if( left < 0 ) left = 0;

    // IE6 fix
    if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();

    $("#simpaleMessageDiv").css({
    top: top + 'px',
    left: left + 'px'
    });

    // window.setTimeout(hideSimpleMessage, 3000);
    } else {
    $("#simpaleMessageDiv").text(arguments[0]);

    // $("#simpaleMessageDiv").fadeIn(200);
    // clearTimeout();
    // window.setTimeout(hideSimpleMessage, 3000);
    }
    $("#simpaleMessageDiv").fadeIn(200).delay(4000).slideUp(200);
    }
      

  7.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>联动</title> <script language="javascript" type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script language="JavaScript" type="text/javascript">
    $(document).ready(function(){
    showSimpleMessage("几秒后消失。");

    });function showSimpleMessage() {
    // if ($("#simpaleMessageDiv").attr("id")=="")
    var flag = document.getElementById("simpaleMessageDiv")==null;
    if (flag) {
    $("BODY").append('<div id="simpaleMessageDiv" style="background-color:yellow">&nbsp;</div>');
    var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 

    $("#simpaleMessageDiv").css({
    position: pos,
    zIndex: 99999,
    padding: 0,
    margin: 0
    });

    $("#simpaleMessageDiv").text(arguments[0]);
    var top = 50;
    var left = (($(window).width() / 2) - ($("#simpaleMessageDiv").outerWidth() / 2)) + 0;
    if( top < 0 ) top = 0;
    if( left < 0 ) left = 0;

    // IE6 fix
    if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();

    $("#simpaleMessageDiv").css({
    top: top + 'px',
    left: left + 'px'
    });

    // window.setTimeout(hideSimpleMessage, 3000);
    } else {
    $("#simpaleMessageDiv").text(arguments[0]);

    // $("#simpaleMessageDiv").fadeIn(200);
    // clearTimeout();
    // window.setTimeout(hideSimpleMessage, 3000);
    }
    $("#simpaleMessageDiv").fadeIn(200).delay(4000).slideUp(200);
    }
    </script>
    </head>
    <body><span id="hiddenId" style="display:none"/>
    </body>
    </html> 
      

  8.   

    重写alert方法的话,我在后台怎么调用呢??如果重写的话,我遇到的问题就是我是通过
    strScript = "<script language=javascript>\n";
                strScript += string.Format("alert('{0}');\n", msg);
                strScript += "</script>"; 
    拼接字符串然后page.ClientScript.RegisterStartupScript写到前台的那我重写之后的话,怎么调用呢?
      

  9.   


    重写也得有function XXX来显示div吧,注册js的时候不调用alert了,调用xxx不就行了