window.event.srcelement not working in firefox

Thảo luận trong 'Lập trình Javascript, js' bắt đầu bởi admin, 18/7/13.

  1. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,884
    Đã được thích:
    1,194
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Khi chay javacrip trên trình duyệt ID, google choome, firefox bạn không bắt được sự kiện Window.event....Bạn khai báo như sau.

    function OpenElement(evt) {
    //fix error window.event.srcElement in firefox
    var myEvent = ((window.event) ? (window.event) : (evt));
    //fix error window.event.srcElement in IE, GoogleChoome
    var Element = ((window.event) ? (event.srcElement) : (evt.currentTarget));
    }

    Bạn áp dụng thêm việc kiểm tra trình duyệt tại -> Kiểm tra trình duyệt người dùng bằng javacrip để javacrip chạy cho đúng.
    Chúc các bạn thành công.
     
    Cảm ơn đã xem bài:

    window.event.srcelement not working in firefox