本帖最后由 xumai3 于 2012-08-14 23:20:39 编辑

解决方案 »

  1.   

    你2个
    window.onload = function () {
    window.onload = getData;后面的会把前面的覆盖掉的
      

  2.   

    你可以 function load1() {
                var tblId = "<%=GridView1.ClientID %>";
                var tbl = $e(tblId);
                if (tbl != null) {
                    for (var i = 1; i < tbl.rows.length; i++) {
                        tbl.rows[i].onclick = new Function("clickRow(this)")
                    }
                }
            }window.onload = function(){
    load1()
    getData()
    }
      

  3.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>
    <script type="text/javascript">
    //LZ问题,其原因在于同一个件事(window.onload)绑定了两个事件,JS会使用后一个事件
    //请看下面的代码:
    //请思考一下,btn被点击时,会运行那一个方法?

    function a(){
    alert("this is first method");
    }

    function b(){
    alert("this is second method");
    } function fn(){
    var btn=document.getElementById("btn");
    btn.onclick=a;
    btn.onclick=b; }//-------------------分隔线------------------------/**如何处理一个件事两个方法?
       答:其实使用件事监听器就可以了。
       请看下面代码:
    */ function fn1(){
    var btn2=document.getElementById("btn2");
    if(document.attachEvent){//IE浏览器

    btn2.attachEvent("onclick",a);
    btn2.attachEvent("onclick",b);
    }else if(document.addEventListener){ //其它浏览器

    btn2.addEventListener("click",a,false);
    btn2.addEventListener("click",b,false);
    }

    }

    </script>
     <body onload="fn();fn1();">
      <input type="button" value="question_1" id="btn"/>
      <input type="button" value="question_2" id="btn2"/>
     </body>
    </html>