문제

I am using the window.load jquery function to preload my home page with a gif image.

Now problem is, that the page freezes/time-out after a while, since all the content has not loaded, and only the gif animation is displayed. However, when reloading the page again, the page loads and hides the preloader like it should, but I don't want users to reload the page everytime.

I use the window.load function specifically because the whole need for the preloader is to preload large images that look crap when loading otherwise (images are in a slider)...

The function: As added right above my ending tag:

<script type="text/javascript">
$(window).load(function()
{
    $("#content").css('display', 'block');
    $("#loading").hide(); //the loader is hidden once content is loaded//
});
</script>

How can I fix this loading 'time-out' issue without refreshing again?

Thank you

도움이 되었습니까?

해결책

I think you should try using document.ready for this :

$(document).ready(function() {
    $("#content").css('display', 'block');
    $("#loading").hide(); //
});

EDIT:

You might try wiating for your content to load :

$('#content').load( function(){
});

Or altenrtivly bind the load to your last image in slider.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top