Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript] Jak to zrobic zeby wyswietlało raz na 24H
Forum PHP.pl > Forum > Przedszkole
bambolo
Witam dobrzy ludzie powiedzcie jak mam za pomocą cookie (chyba najlepiej) zrobic zeby oto ten skrypt wywalał mi okienko raz na 24h sad.gif a nie tak jak jest teraz co odswierzanie strony mi go ładuje sad.gif

  1.  
  2. <link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
  3.  
  4. <script type="text/javascript" src="windowfiles/dhtmlwindow.js">
  5.  
  6. /***********************************************
  7.  
  8. * DHTML Window Widget- Š Dynamic Drive (www.dynamicdrive.com)
  9.  
  10. * This notice must stay intact for legal use.
  11.  
  12. * Visit <a href="http://www.dynamicdrive.com/" target="_blank">http://www.dynamicdrive.com/</a> for full source code
  13.  
  14. ***********************************************/
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. <link rel="stylesheet" href="modalfiles/modal.css" type="text/css" />
  22.  
  23. <script type="text/javascript" src="modalfiles/modal.js"></script>
  24.  
  25. </head>
  26.  
  27.  
  28. <!-##################### 1) DHTML Modal Window Example 1: ###################-->
  29.  
  30. <script type="text/javascript">
  31.  
  32.  
  33. var agreewin=dhtmlmodal.open("agreebox", "iframe","/zakaz.gif", "This image has been marked as adult content. You must be 18 years of age or older to proceed.", "width=300px,height=300px,center=1,resize=1,scrolling=0", "recal")
  34.  
  35.  
  36.  
  37. agreewin.onclose=function(){ //Define custom code to run when window is closed
  38.  
  39. var theform=this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
  40.  
  41. var yesbox=theform.eulabox[0] //Access the first radio button within form
  42.  
  43. var nobox=theform.eulabox[1] //Access the second radio button within form
  44.  
  45. if (yesbox.checked==true)
  46.  
  47. alert("You agreed to the terms")
  48.  
  49. else if (nobox.checked==true)
  50.  
  51. alert("You didn't agree to the terms")
  52.  
  53. return true //Allow closing of window in both cases
  54.  
  55. }
  56.  
  57.  
  58.  
MateuszS
na poczatku (!), na samym poczatku kodu w 1 linijcie <? ob_start(); ?> i w ostatniej <? ob_end flush(); ?>

i teraz

  1. if(!isset($_COOKIE['ciacho'])) {
  2. //tutaj ten skrypt twoj i pod spodem:
  3.  
  4. setcookie('ciacho','1',time()+3600*24);
  5. }


bambolo
Baardzo bym Cie prosił jak to ma dokładnie wyglądac bo mi jakies błędy wywala sad.gif pliiss przylep to tu smile.gif
i cos nie dziala sad.gif mimo ze wyczysciłem ciacha teraz wogule nie pojawia sie okienko
MateuszS
  1. <? ob_start(); ?>
  2. <html>
  3. <head>
  4.  
  5. <link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
  6.  
  7. <script type="text/javascript" src="windowfiles/dhtmlwindow.js">
  8.  
  9. /***********************************************
  10.  
  11. * DHTML Window Widget- ? Dynamic Drive (www.dynamicdrive.com)
  12.  
  13. * This notice must stay intact for legal use.
  14.  
  15. * Visit http://www.dynamicdrive.com/ for full source code
  16.  
  17. ***********************************************/
  18.  
  19.  
  20.  
  21. </script>
  22.  
  23.  
  24.  
  25. <link rel="stylesheet" href="modalfiles/modal.css" type="text/css" />
  26.  
  27. <script type="text/javascript" src="modalfiles/modal.js"></script>
  28.  
  29. </head>
  30.  
  31. <body>
  32.  
  33. <!-##################### 1) DHTML Modal Window Example 1: ###################-->
  34.  
  35. <? if(!isset($_COOKIE['ciacho'])) { ?>
  36. <script type="text/javascript">
  37.  
  38.  
  39. var agreewin=dhtmlmodal.open("agreebox", "iframe","/zakaz.gif", "This image has been marked as adult content. You must be 18 years of age or older to proceed.", "width=300px,height=300px,center=1,resize=1,scrolling=0", "recal")
  40.  
  41.  
  42.  
  43. agreewin.onclose=function(){ //Define custom code to run when window is closed
  44.  
  45. var theform=this.contentDoc.getElementById("eula") //Access form with id="eula" inside iframe
  46.  
  47. var yesbox=theform.eulabox[0] //Access the first radio button within form
  48.  
  49. var nobox=theform.eulabox[1] //Access the second radio button within form
  50.  
  51. if (yesbox.checked==true)
  52.  
  53. alert("You agreed to the terms")
  54.  
  55. else if (nobox.checked==true)
  56.  
  57. alert("You didn't agree to the terms")
  58.  
  59. return true //Allow closing of window in both cases
  60.  
  61. }
  62.  
  63.  
  64. </script>
  65.  
  66. <?
  67. setcookie('ciacho','1',time()+3600*24);
  68. } ?>
  69. </body>
  70. </html>
  71. <? ob_end_flush(); ?>



i pisz jakie bledy ci wywala
bambolo
działa działa smile.gif the a jak teraz bym chciał na 6-12 lub 24h to tylko zmienie to
  1. setcookie('ciacho','1',time()+3600*24);
  2. setcookie('ciacho','1',time()+3600*12);
  3. setcookie('ciacho','1',time()+3600*6);


Dobrze gadam ?
MateuszS
tak w ogole to co ty chcesz ukryc? ktory kod? ten w head czy ten w body?
bambolo
Juz wszystko dział smile.gif thx
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.