
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:
<html> <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN''http://www.w3.org/TR/html4/strict.dtd'> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <style type="text/css"> @import "jquery.countdown.css"; #shortly { width: 240px; height: 45px; } </style> <script>!window.jQuery && document.write('<script src="jquery.min.js"><\/script>')</script> <script type="text/javascript" src="jquery.countdown.js"></script> <script type="text/javascript"> var shortly = null; $('#shortly').countdown({until: shortly, onExpiry: liftOff, onTick: watchCountdown}); $('#shortlyStart').click(function() { shortly = new Date(); shortly.setSeconds(shortly.getSeconds() + 5.5); $('#shortly').countdown('change', {until: shortly}); }); function liftOff() { alert('We have lift off!'); } function watchCountdown(periods) { $('#monitor').text('Just ' + periods[5] + ' minutes and ' + periods[6] + ' seconds to go'); </script> </head> <body> </body> </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:
<html> <head> <style type="text/css">@import "jquery.countdown.css"; </style> <script type="text/javascript"> $(document).ready(function(){ var today = new Date(); today.setSeconds(today.getSeconds() + 3); $('#defaultCountdown').countdown({until: today, onExpiry: onEndCountdown, onTick: onWatchCountdown}); }); function onEndCountdown() { alert('To juz koniec !'); } function onWatchCountdown(periods) { $('#describeCountdown').text('Zostalo ' + periods[5] + ' minut i ' + periods[6] + ' sekund do konca.'); } </script> </head> <body> </body> </html>