I'm running a script (hack) to trick Safari into correctly sizing a video on a responsive page. The script below waits a moment then hides, and then shows a video, causing Safari to realize it should expand the video to its proper size.
I'm worried that $(document).ready
may fire the script too soon (i.e., before the video is loaded), thus causing the script not to do what it is supposed to do to the video. Is it possible that with $(document).ready
the script may fire but since the video isn't loaded after the set milliseconds that the video will not be hidden/shown?
Should I use window.onload
(or another method?) instead to ensure that my hide/show sizing hack works?
In my tests, the script mostly works, even on reloads when I clear the cache. But a few times when I've loaded the page on random computers the video will not size correctly until I reload the page. Using window.onload
seems less ideal in that a user may notice the incorrectly sized video while the page content is loading, or see the hack in action after it does.
<script><!-- Super hack to toggle display block/none which tricks Safari into properly sizing video-->
$(document).ready(function() {
$("#video1").delay(3000).hide(0, function() {
$("#video1").delay(3500).show();
});
});
</script>