Window onload event does not fire in ipad ios 8.4

后端 未结 3 1699

I am facing following strange issue:

Functionality:
When I open my website page which has many images and have javascript/jquery used for clie

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-16 12:10

    There is also a workaround:

    var iOS8 = navigator.userAgent.match(/(iPad|iPhone|iPod).*OS 8_\d/i);
    if( iOS8 ){
        setTimeout(function(){
            $(window).trigger('load');
        }, 3500);
    }
    

    This will trigger the load, and 'trick' Safari on iOS8 to think that the $(window) object was loaded, so the code inside the

    $(window).on('load', function());
    

    will work.

    Hope this helps to anyone who is searching for this :)

提交回复
热议问题