Witam,
W jaki sposób mogę opóźnić wykonanie się tego skryptu o np. 10 sekund?
Ktoś wchodzi na strone i odrazu wyskakuje mu popup, chciałbym żeby wyskakiwał po 10 sekundach
<script type="text/javascript">
var popupStatus = 0;
//this code will load popup with jQuery magic!
function loadPopup(){
//loads popup only if it is disabled
if(popupStatus==0){
$("#overlay").css({
"opacity": "0.7"
});
$("#overlay").fadeIn("slow");
$("#boxpopup").fadeIn("slow");
popupStatus = 1;
}
}
//This code will disable popup when click on x!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#overlay").fadeOut("slow");
$("#boxpopup").fadeOut("slow");
popupStatus = 0;
}
}
//this code will center popup
function centerPopup(){
//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#boxpopup").height();
var popupWidth = $("#boxpopup").width();
//centering
$("#boxpopup").css({
"position": "fixed",
"top": windowHeight/2-popupHeight/2
});
//only need force for IE6
$("#overlay").css({
"height": windowHeight
});
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
if ($.cookie("news") != 1) {
//centering with css
centerPopup();
//load popup
loadPopup();
}
//CLOSING POPUP
//Click the x event!
$("#boxpopupClose").click(function(){
disablePopup();
$.cookie("news", "1", { expires: 14 });
});
//Click out event!
$("#overlay").click(function(){
disablePopup();
$.cookie("news", "1", { expires: 14 });
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
$.cookie("news", "1", { expires: 14 });
}
});
});
</script>