本帖最后由 beichui 于 2012-03-01 10:56:23 编辑

解决方案 »

  1.   

    不大明白你说的,是这个意思吗?<script type="text/javascript">
    function fire(input){
        alert(input.id)
    }
    </script><input type="text" id="abc" onfocus="fire(this)" />
    <input type="text" id="abd" onfocus="fire(this)" />
      

  2.   

    你的理解和我说的差不多,但是我不想传任何和页面相关的参数,包括把THIS当参数传递进去。而是在函数内部自己获得调用者。
      

  3.   

    <body>
    <div id="a1" onclick="t()">只在IE下有效</div>
    <script>
    t = function(){
    alert(window.event.srcElement.id);
    }
    </script>
    </body>
      

  4.   

    $(document).ready(function(){
    $("#abc").focus(function(){
       alert($(this).attr("id"));
    });
    });<input type="text" id="abc" onfocus="javascript:function()/>
      

  5.   

    非常感谢,IE下解决了,不过火狐还是必须把EVENT当参数传递进去,不知道有没办法兼容火狐?
      

  6.   

    朋友,你这个还是没有解决,$("#abc")等于还是写死了标签ID。
      

  7.   

    找了下资料,解决了,引用一段牛人重新的火狐Event事件就可以了。/*firefox*/
    function __firefox(){
        HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
        window.constructor.prototype.__defineGetter__("event", __window_event);
        Event.prototype.__defineGetter__("srcElement", __event_srcElement);
    }
    function __element_style(){
        return this.style;
    }
    function __window_event(){
        return __window_event_constructor();
    }
    function __event_srcElement(){
        return this.target;
    }
    function __window_event_constructor(){
        if(document.all){
            return window.event;
        }
        var _caller = __window_event_constructor.caller;
        while(_caller!=null){
            var _argument = _caller.arguments[0];
            if(_argument){
                var _temp = _argument.constructor;
                if(_temp.toString().indexOf("Event")!=-1){
                    return _argument;
                }
            }
            _caller = _caller.caller;
        }
        return null;
    }
    if(window.addEventListener){
        __firefox();
    }
    /*end firefox*/最后感谢下所有回答的朋友