Loading jQuery window in iOS 8

I recently upgraded my phone to iOS 8 and I am now experiencing some really unusual behavior.

Below is a demo of the problem:

<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
alert("A");
jQuery(window).load(function(){
    alert("B"); 
});
</script>

      

In Safari iOS 7, this brings up the "A" and "B" dialog boxes. But when viewed in Safari iOS 8, only the "A" dialog box appears.

Any ideas on why window loading won't work in iOS 8?

+3


source to share


2 answers


I don't have a real solution for this, but if you have or on your page, Safari on iOs8 doesn't fire the load event.

So, you have at least 2 solutions:

  • count your external files like images, css, scripts and attach upload to them and wait for the last .load of these files
  • write your video / audio tag after load events


// EDIT: So I'm writing this, which helped me to still use the video:

var $video = $('.player');
$video.each(function(){
    this.outerHTML = this.outerHTML.replace('div', 'video')
});
$video = $('.player');

      

See the Browser Compatibility section to see if outerHTML matches your compatibility https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML#Browser_compatibility

+1


source


Use window.onload = function(){ };

as jQuery(window).load(function(){ });

I can fix this problem in my project.



0


source







All Articles