간단한 팝업이 나타날 때까지 내 페이지에서 5 ~ 10 초 동안 머 무르려면 방문자가 필요합니다. 닫기 버튼이 30 초 후에 나타나지만 그림자를 제외한 다른 요소는 페이지 외부의 잘못된 위치에 나타 났으므로 setTimeout 함수를 시도했습니다. 여기에 올바른 아이디어가 있습니까?10 초 후에 팝업을 표시하려면이 코드에 무엇을 추가해야합니까?
var shadow = $('<div id="shadowElem"></div>');
var speed = 1000;
$(document).ready(function() {
$('body').prepend(shadow);
});
$(window).load(function() {
screenHeight = $(window).height();
screenWidth = $(window).width();
elemWidth = $('#dropElem').outerWidth(true);
elemHeight = $('#dropElem').outerHeight(true)
leftPosition = (screenWidth/2) - (elemWidth/2);
topPosition = (screenHeight/2) - (elemHeight/2);
setTimeout(function() {
$("#dropClose").show();
}, 30 * 1000);
$('#dropElem').css({
'left' : leftPosition + 'px',
'top' : -elemHeight + 'px'
});
$('#dropElem').show().animate({
'top' : topPosition
}, speed);
shadow.animate({
'opacity' : 0.7
}, speed);
$('#dropClose').click(function() {
shadow.animate({
'opacity' : 0
}, speed);
$('#dropElem').animate({
'top' : -elemHeight + 'px'
}, speed, function() {
shadow.remove();
$(this).remove();
});
});
});
나는 shadowElem을 7 * 1000으로 만들 것이라고 생각한다. dropElem과 같은 뜻이다. –