在body里边把所有的事件都写上啊!然后处理事件响应就行了吧

解决方案 »

  1.   

    有空帮你写了个demo<input type="button" id="testbtn" value="click me and watch status bar !"/>
    <script type="text/javascript">
    function addEventHandler(target, type, func) {
        if (target.addEventListener) {
            target.addEventListener(type, func, false);
        } else if (target.attachEvent) {
            target.attachEvent("on" + type, func);
        } else {
         target["on" + type] = func;
        }
    }
    function $(element) {
    if (typeof element == 'string')
    return document.getElementById(element);
    }
    function showstatus(str) {
    if (typeof str == 'string')
    window.status = str;
    }
    addEventHandler($('testbtn'), 'click', function(){
    showstatus('you clicked testbtn !');
    });
    </script>
      

  2.   

    晕, 楼上的是加兼容事件,  LZ要的是监听。     监听所有不知道, 
    不过想想事件的传递性 可以实现 一部分吧。
    例如:onclick 事件
    在body里面加下这个事件后 点击body的单击就会向上传递(前提你没有关闭这种传递),所有的点击就都有了, 不一定对, 刚想的。   
      

  3.   

    哦 这个意思 那改一下吧 :)<input type="button" id="testbtn" value="click me and watch status bar !"/>
    <script type="text/javascript">
    function addEventHandler(target, type, func) {
        if (target.addEventListener) {
            target.addEventListener(type, func, false);
        } else if (target.attachEvent) {
            target.attachEvent("on" + type, func);
        } else {
         target["on" + type] = func;
        }
    }
    function $(element) {
    if (typeof element == 'string')
    return document.getElementById(element);
    }
    function showstatus(str) {
    if (typeof str == 'string')
    window.status = window.status + '>' + str;
    }
    function cleanstatus() {
    setTimeout(function(){window.status=''}, 1000);
    }
    addEventHandler($('testbtn'), 'click', function(){
    showstatus('clicked testbtn');
    });
    addEventHandler(document, 'click', function(){
    showstatus('clicked document');
    cleanstatus();
    });
    </script>
      

  4.   

    <html>
    [code=HTML]
    <html>
    <input id='a'/>
    <script>
    function show(){
    window.status = event.srcElement.tagName + ":" + event.type;
    }
    document.body.onload= function(){
    for(var i=0; i<document.all.length; i++){
    var el = document.all[i];
    for(j in el)
    {
    if(j.match(/^on/)!=null)
    el.attachEvent(j,show);
    }
    }}
    </script>
    </html>
    [code]写完才知道...
    某个事件在某个地方是持续发生的...
      

  5.   

    <html>
    <input id='a'/>
    <script>
    function show(){
    window.status = event.srcElement.tagName + ":" + event.type;
    }
    document.body.onload= function(){
    for(var i=0; i<document.all.length; i++){
    var el = document.all[i];
    for(j in el)
    {
    if(j.match(/^on/)!=null)
    el.attachEvent(j,show);
    }
    }}
    </script>
    </html>