sandrulis Posted September 7, 2009 Report Share Posted September 7, 2009 Man ir vajadzīga palīdziba at laiku atskaiti! Doma tāda, ar JavaScript panākt tā, ka laika atskaita sākas no 30 sec un līdz 0, ja laika atskaite ir tikusi uz 0, tad automatiski, lapa tiek pārlādēta uz citu. Nu piemērām vis notiek lapa1, bet kad javascrip tiek uz 0, tad ar šādu funkciju (<meta http-equiv="refresh" content="0;url=lapa2">), bet protams var gan jau ar citu ar! Quote Link to comment Share on other sites More sharing options...
Maris-S Posted September 7, 2009 Report Share Posted September 7, 2009 Tak tam meta tagam 0 vietā norādi 30 un viņa aizies pēc 30 sekundēm, vienīgi ņem vērā ka šis meta tags nav w3c standarts, iespējama neprecīza darbība dažādos pārlūkos. http://en.wikipedia.org/wiki/Meta_refresh Quote Link to comment Share on other sites More sharing options...
Maris-S Posted September 7, 2009 Report Share Posted September 7, 2009 Labāk kā alternatīvu izmanto javascript: <script type="text/javascript"> <!-- setTimeout('Redirect()',3000); function Redirect() { location.href = 'www.new_home_page.com'; } --> </script> Šeit var palasīt: http://www.cryer.co.uk/resources/javascript/script5.htm Quote Link to comment Share on other sites More sharing options...
sandrulis Posted September 7, 2009 Author Report Share Posted September 7, 2009 Nja tada doma jau man ir, bet es gribu, lai lapas apskatītājs redz cik vēl laiks ir atlicis! :( Quote Link to comment Share on other sites More sharing options...
marcis Posted September 7, 2009 Report Share Posted September 7, 2009 Kaut kā šitā <span id="laika-atskaite">30</span> <script type="text/javascript"> var laiks = 30; function update(){ laiks--; document.getElementById("laika-atskaite").innerHTML = laiks; if(laiks == 0){ document.location.href = 'http://cita.lapa'; return; } window.setTimeout('update()', 1000); } window.onload = function(){ update(); } </script> Quote Link to comment Share on other sites More sharing options...
Maris-S Posted September 7, 2009 Report Share Posted September 7, 2009 Sorry, palaidu garām ka skaitītājam vizuāli jārādās. Quote Link to comment Share on other sites More sharing options...
sandrulis Posted September 7, 2009 Author Report Share Posted September 7, 2009 Kaut kā šitā <span id="laika-atskaite">30</span> <script type="text/javascript"> var laiks = 30; function update(){ laiks--; document.getElementById("laika-atskaite").innerHTML = laiks; if(laiks == 0){ document.location.href = 'http://cita.lapa'; return; } window.setTimeout('update()', 1000); } window.onload = function(){ update(); } </script> O, paldies, šis ritīgais! :) Quote Link to comment Share on other sites More sharing options...
sandrulis Posted September 7, 2009 Author Report Share Posted September 7, 2009 Maris-S ta bija mana vaina, es no sakuma laikam isti tā nepaskaidroju! Quote Link to comment Share on other sites More sharing options...
KarlisBa Posted September 7, 2009 Report Share Posted September 7, 2009 Ar meta tagu var gadīties, ka refresh jeb redirect var nestrādāt, bet ar JS kodu tas vienmēr strādās? Quote Link to comment Share on other sites More sharing options...
Maris-S Posted September 7, 2009 Report Share Posted September 7, 2009 Ja lietotāja pārlūkam būs atslēgts javascripts, tad nestrādās. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.