Cross Browser Dom Ready

前端 未结 3 1489
夕颜
夕颜 2020-12-23 17:43

I inherited this piece of code and it seems suboptimal and possibly incorrect since it\'s adding event listeners on both the window and document objects. However, it is wor

3条回答
  •  没有蜡笔的小新
    2020-12-23 18:17

    Personally I'd use jQuery for this.

    jQuery is designed to handle the variety of different browser implimentations of the document ready state.

    Using jQuery your above code would look like:

    $(callback);
    

提交回复
热议问题