페이지가 약간 지연되어로드 된 후 외부 소스에서 div를로드하려고합니다.jquery 페이지 로딩 지연
여기 jquery 스크립트가 있습니다. 콘텐츠는 먼저로드되고 나중에 loader.gif가 발생합니다. 몇 xx 시간 후에 외부 소스의 컨텐츠를 어떻게 표시 할 수 있습니까? .load()
기능에 대한 아이디어가 있지만 구현 방법을 잘 모릅니다. 당신은 몸이로드되는 동안 DIV를 보여 온로드 숨길 필요가 jquery website
The load event is sent to an element when it and all sub-elements have been
completely loaded. This event can be sent to any element associated with a URL:
images scripts, frames, iframes, and the window object.
에서
$(window).load(function() {
$('<div id="overlay"><img src="loading.gif" /></div>')
.css('opacity', '0.5')
.insertAfter('body');
window.setTimeout(function() {
$(document).ready(function() {
$('#overlay').remove();
});}, 1000);
$('.body').show();
});
<div id="container">
<div id="header">navigation</div>
<div id="body" class="body">Body</div>
<div id="footer">footer</div>
</div>
#overlay {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: gray;
}
.body{display:none;}
#overlay img {
display: block;
width: 32px;
height: 32px;
position: absolute;
top: 50%;
left: 50%;
margin: -26px 0 0 -26px;
padding: 10px;
background: #fff;
-moz-border-radius: 6px;
border-radius: 6px;
}
네, 실제로 제가 여기서 찾고있는 것이 아닙니다. 본문 div에로드되는 콘텐츠가 무거울 것입니다. 그래서, 나는 메인 페이지를 먼저로드하고 body div 컨텐츠를 .load() 함수를 사용하여로드하려고한다. – Ravi