Od razu zaznaczam, że nie znam się na JS smile.gif.

Chciałbym wywołać timer pochodzący z tej strony:
http://keith-wood.name/countdown.html
"Callback Events" -> "Action it in 5 seconds...". Aktualnie mój kod wygląda tak:
  1. <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN''http://www.w3.org/TR/html4/strict.dtd'>
  2. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  3. <style type="text/css">
  4. @import "jquery.countdown.css";
  5. #shortly { width: 240px; height: 45px; }
  6. <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  7. <script>!window.jQuery && document.write('<script src="jquery.min.js"><\/script>')</script>
  8. <script type="text/javascript" src="jquery.countdown.js"></script>
  9. <script type="text/javascript">
  10. var shortly = null;
  11. $('#shortly').countdown({until: shortly,
  12. onExpiry: liftOff, onTick: watchCountdown});
  13.  
  14. $('#shortlyStart').click(function() {
  15. shortly = new Date();
  16. shortly.setSeconds(shortly.getSeconds() + 5.5);
  17. $('#shortly').countdown('change', {until: shortly});
  18. });
  19.  
  20. function liftOff() {
  21. alert('We have lift off!');
  22. }
  23.  
  24. function watchCountdown(periods) {
  25. $('#monitor').text('Just ' + periods[5] + ' minutes and ' +
  26. periods[6] + ' seconds to go');
  27. </head>
  28. <span id="shortly" class="countdown"></span>
  29. <button type="button" id="shortlyStart">Start</button>
  30. </body>
  31. </html>

... i nie działa.
Co ciekawe domyślny timer z dokumentacji działa: KOD
Prosiłbym o poprawienie kodu lub wskazanie błędów.

Problem rozwiązany!

Oto poprawny kod:
  1.  
  2. <style type="text/css">@import "jquery.countdown.css";
  3.  
  4. <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  5. <script type="text/javascript" src="jquery.countdown.js"></script>
  6. <script type="text/javascript">
  7.  
  8. $(document).ready(function(){
  9.  
  10. var today = new Date();
  11. today.setSeconds(today.getSeconds() + 3);
  12. $('#defaultCountdown').countdown({until: today, onExpiry: onEndCountdown, onTick: onWatchCountdown});
  13.  
  14. });
  15.  
  16. function onEndCountdown() {
  17. alert('To juz koniec !');
  18. }
  19.  
  20. function onWatchCountdown(periods) {
  21. $('#describeCountdown').text('Zostalo ' + periods[5] + ' minut i ' + periods[6] + ' sekund do konca.');
  22. }
  23.  
  24. </head>
  25.  
  26.  
  27. <div id="defaultCountdown"></div>
  28. <div id="describeCountdown"></div>
  29.  
  30. </body>
  31. </html>