Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [js] J+Uruchamianie skryptu po czasie
mariusz1985
post
Post #1





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

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


Witam mam pytanie
Mam taką funkcje na swojej stronie i co mam zrobić żeby funkcja ta wywołała się dopiero np po 5 sekundach od otwarcia strony
Ponieważ teraz startuje odrazu questionmark.gif

Proszę o pomoc


  1. <script language="JavaScript" type="text/javascript">
  2.  
  3. <!--hide
  4.  
  5. //STEP 1: PUT THIS CODE INTO THE HEAD OF YOUR DOCUMENT
  6.  
  7. var wdmax=140; //set maximum width of square image (px)
  8.  
  9. var wdmin=0; //set minimum thickness of edge-on image (px)
  10.  
  11. var inc=5; //set step change in px (wdmax-wdmin must be a multiple) )These two variables
  12.  
  13. var rate = 50; //pause between steps (in millisec) )determine flip-flop speed
  14.  
  15. var pause = 1000; //pause between flip and flop (in millisec)
  16.  
  17. var ff="flip"; //initialise whether movement starts with a "flip" (sideways) or "flop" (vertical) change.
  18.  
  19.  
  20.  
  21. function flipflop() {
  22.  
  23.  
  24. if (ff=="flip") {
  25.  
  26. var wd = document.getElementById("pic").getAttribute("height");
  27.  
  28. wd = wd - inc;
  29.  
  30. document.getElementById("pic").setAttribute("height",wd);
  31.  
  32.  
  33.  
  34. if (wd==wdmin) {
  35.  
  36. document.getElementById("pic").setAttribute("src","bcard2.png"); //substitute name of your second picture
  37.  
  38. inc=-inc;
  39.  
  40. }
  41.  
  42. if (wd==wdmax) {
  43.  
  44. ff="flop";
  45.  
  46. inc=-inc;
  47.  
  48. setTimeout("flipflop()",5000);
  49.  
  50. }
  51.  
  52. else {
  53.  
  54. setTimeout("flipflop()",rate);
  55.  
  56. }
  57.  
  58.  
  59. }
  60.  
  61. else {
  62.  
  63. var ht = document.getElementById("pic").getAttribute("height");
  64.  
  65. ht = ht - inc;
  66.  
  67. document.getElementById("pic").setAttribute("height",ht);
  68.  
  69. if (ht==wdmin) {
  70.  
  71. document.getElementById("pic").setAttribute("src","bcard1.png"); //substitute name of your first picture
  72.  
  73. inc=-inc;
  74.  
  75. }
  76.  
  77. if (ht==wdmax) {
  78.  
  79. ff="flip";
  80.  
  81. inc=-inc;
  82.  
  83. setTimeout("flipflop()",1000);
  84.  
  85. }
  86.  
  87. else {
  88.  
  89. setTimeout("flipflop()",rate);
  90.  
  91. }
  92.  
  93. }
  94.  
  95.  
  96. }
Go to the top of the page
+Quote Post
skowron-line
post
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


settimeout w body i onload


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
mariusz1985
post
Post #3





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

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


Witam ale jak mam to umieścić w <body>

ja mam teraz tak :

  1. <body bgcolor="#BDD10D" onload="initLightbox() ; flipflop() ; flipflop2() ; flipflop1()">


i jak mam tu dodać setTimeout żeby flipflop startował po 1 sek , flipflop1 po 2 sek i flipflop2 po 3 sek
Go to the top of the page
+Quote Post
skowron-line
post
Post #4





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


  1. function execute()
  2. {
  3. setTimeOut( 'flipflop1',2000);
  4. setTimeOut( 'flipflop2',3000);
  5. }
  6. <body onload="initLightbox() ; execute();"


Coś w ten deseń. Pisane z palca.


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
mariusz1985
post
Post #5





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

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


niestety nie działa
nie wiem czemu. Na moje oko to powinno być poprawnie ale cały niestety wywala błąd i wcale się skrypt nie uruchamia. sad.gif
Go to the top of the page
+Quote Post
skowron-line
post
Post #6





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


Jaki błąd.
Sprawdziłeś kod który Ci podałem
bo źle napisałem powinno być
setTimeout a nie setTimeOut.

Kod
function execute()
{
setTimeout( 'flipflop1()',2000);
setTimeout( 'flipflop2()',3000);
}
<body onload="initLightbox(); execute();"


Ten post edytował skowron-line 5.04.2009, 23:35:05


--------------------
I'm so fast that last night I turned off the light switch in my hotel room and was in bed before the room was dark - Muhammad Ali.
Peg jeżeli chcesz uprawiać sex to dzieci muszą wyjść, a jeżeli chcesz żeby był dobry ty też musisz wyjść - Al Bundy.

QueryBuilder, Mootools.net, bbcradio1::MistaJam
http://www.phpbench.com/
Go to the top of the page
+Quote Post
mariusz1985
post
Post #7





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

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


zadziałało

Dzięki za szybkie odpowiedzi

Nie przypuszczałem że taki błąd może mieć znaczenie teraz będę bardziej zwracał uwagę na takie rzeczy.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 22.08.2025 - 08:31