| | |
| Stránka: 1 z 1
| [ Príspevkov: 2 ] | |
Autor | Správa |
---|
Registrovaný: 28.07.09 Prihlásený: 18.04.13 Príspevky: 145 Témy: 42 |
mam scritp na vypis času
Kód: <script type='text/javascript'> function calctime() { var currenttime = new Date(); var hours = currenttime.getHours(); var minutes = currenttime.getMinutes(); var seconds = currenttime.getSeconds(); if (hours == 0) { hours = 12; } if (hours < 10) { hours = \"0\" + hours; } if (minutes < 10) { minutes = \"0\" + minutes; } if (seconds < 10) { seconds = \"0\" + seconds; } var clocklocation = document.getElementById('digitalclock'); clocklocation.innerHTML = hours + \":\" + minutes + \":\" + seconds; setTimeout(\"calctime()\", 1000); } calctime(); </script> validator mi vypíše tuto chybu Kód: Line 45, Column 13: character "<" is the first character of a delimiter but occurred as data
if (hours < 10)
✉
This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "<" * You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe. * Another possibility is that you forgot to close quotes in a previous tag.
skušal som to nahradiť < ale ani to nešlo
je ešte nejake riešenie?
|
|
Registrovaný: 11.08.07 Príspevky: 4088 Témy: 34 Bydlisko: Brno | Napísal Ďuri: 09.02.2010 13:40 | |
|
Dobre, trochu teorie - validator vidi znak <, preto ocakava zapis nejakej znacky, ale ziadna tam nie je. Pouzit < nemozes, lebo v <script>e sa entity neprekladaju. Mas niekolko moznosti. Bud ten skript vloz ako externy, alebo pouzi zapis, aby vnutro skriptu validator ignoroval. Ak pises v HTML, pouzi klasicky komentar - <!-- ... -->, robi sa to takto:
Kód: <script> <!-- skript //--> </script> Ak pises v skutocnom XHTML (urcite nie tvoj pripad), mozes pouzit <![CDATA[ ... ]]>. Ak deklarujes XHTML, ale pouzivas HTML, tiez pouzi komentar alebo vloz CDATA zapis do Javascriptoveho komentaru(druhy sposob je dost zbytocny, aj ked rozsireny).
|
|
| Stránka: 1 z 1
| [ Príspevkov: 2 ] | |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|