<input type="submit" name="sb1" id="sb1" value="查询"></input>
<a href="#" class="btn" onclick="on_click()">导出</a>当我点击 导出 时, 怎么判断查询被点击了?
<script type="text/javascript">
function on_click(){
     if(??????)
      alert("查询被点击了!");
        }
</script>

解决方案 »

  1.   

    定义Boolean变量,查询被点击时赋值,再对该变量作判断
      

  2.   

    不太明白楼主的意思?是否是这样?<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script language="javascript" type="text/javascript">
            window.onload = function () {
                var btn = document.getElementById("btnSearch");
                if (window.attachEvent) {
                    btn.attachEvent("onclick", ClickButton,false);
                } else {
                    btn.addEventListener("click", ClickButton,false);
                }        }
            function ClickButton(){
                alert("点击了查询按钮");
            }
        </script>
    </head>
    <body>
        <input type="button" value="查询" id="btnSearch" />
    </body>
    </html>
      

  3.   

    var isClick=false;function on_click(){
    if(!isClick){
    isClick=true;
    alert("第一次被点击");
    }
    else
    alert("已经被点击过");
      }
      

  4.   


    if(event.srcElement.className =='btn'){
      alert('button pressed');
     }
    else{
     alert('button not pressed');
    }