Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Opóźnienie wykonania skryptu
Kaluza
post
Post #1





Grupa: Zarejestrowani
Postów: 35
Pomógł: 0
Dołączył: 4.12.2010

Ostrzeżenie: (0%)
-----


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

  1. <script type="text/javascript">
  2.  
  3. var popupStatus = 0;
  4. //this code will load popup with jQuery magic!
  5. function loadPopup(){
  6. //loads popup only if it is disabled
  7. if(popupStatus==0){
  8. $("#overlay").css({
  9. "opacity": "0.7"
  10. });
  11. $("#overlay").fadeIn("slow");
  12. $("#boxpopup").fadeIn("slow");
  13. popupStatus = 1;
  14. }
  15. }
  16.  
  17. //This code will disable popup when click on x!
  18. function disablePopup(){
  19. //disables popup only if it is enabled
  20. if(popupStatus==1){
  21. $("#overlay").fadeOut("slow");
  22. $("#boxpopup").fadeOut("slow");
  23. popupStatus = 0;
  24. }
  25. }
  26.  
  27. //this code will center popup
  28. function centerPopup(){
  29. //request data for centering
  30. var windowWidth = document.documentElement.clientWidth;
  31. var windowHeight = document.documentElement.clientHeight;
  32. var popupHeight = $("#boxpopup").height();
  33. var popupWidth = $("#boxpopup").width();
  34. //centering
  35. $("#boxpopup").css({
  36. "position": "fixed",
  37. "top": windowHeight/2-popupHeight/2
  38. });
  39. //only need force for IE6
  40. $("#overlay").css({
  41. "height": windowHeight
  42. });
  43.  
  44. }
  45. //CONTROLLING EVENTS IN jQuery
  46. $(document).ready(function(){
  47. if ($.cookie("news") != 1) {
  48. //centering with css
  49. centerPopup();
  50. //load popup
  51. loadPopup();
  52. }
  53. //CLOSING POPUP
  54. //Click the x event!
  55. $("#boxpopupClose").click(function(){
  56. disablePopup();
  57. $.cookie("news", "1", { expires: 14 });
  58. });
  59. //Click out event!
  60. $("#overlay").click(function(){
  61. disablePopup();
  62. $.cookie("news", "1", { expires: 14 });
  63. });
  64. //Press Escape event!
  65. $(document).keypress(function(e){
  66. if(e.keyCode==27 && popupStatus==1){
  67. disablePopup();
  68. $.cookie("news", "1", { expires: 14 });
  69. }
  70. });
  71. });
  72. </script>
Go to the top of the page
+Quote Post
erix
post
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Wrzuć kod ograniczony warunkiem w:
[JAVASCRIPT] pobierz, plaintext
  1. if ($.cookie("news") != 1) {
[JAVASCRIPT] pobierz, plaintext

Do setTimeout.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 10.01.2026 - 12:17