[XHTML] Niesamowite błędy walidacji

0

Witajcie [!!!]

Mam pewien problem ze skryptami na mojej stronie - skrypt zegarka wyświetla się tylko pod IE i Operą, a pod Firefox'em i Netscape'em po prostu znika, natomiast przy walidacji skryptu daty W3C piszczy, że nie wolno mi używać zwykłych znaqw matematycznych.

Ale po kolei - najpierw kod skryptów:

<script language="javascript" type="text/javascript">

DayName = new Array(7)
DayName[0] = "niedzielę"
DayName[1] = "poniedziałek"
DayName[2] = "wtorek"
DayName[3] = "środę"
DayName[4] = "czwartek "
DayName[5] = "piątek"
DayName[6] = "sobotę"

MonthName = new Array(12)
MonthName[0] = "stycznia"
MonthName[1] = "lutego"
MonthName[2] = "marca"
MonthName[3] = "kwietnia"
MonthName[4] = "maja"
MonthName[5] = "czerwca"
MonthName[6] = "lipca"
MonthName[7] = "sierpnia"
MonthName[8] = "września"
MonthName[9] = "października"
MonthName[10] = "listopada"
MonthName[11] = "grudnia"

function getDateStr(){

    var Today = new Date()
    var WeekDay = Today.getDay()
    var Month = Today.getMonth()
    var Day = Today.getDate()
    var Year = Today.getFullYear()

    if(Year<=99)
        Year += 1900

    document.write("Dzisiaj mamy " + DayName[WeekDay] +  "," + " " + Day + " " + MonthName[Month] + " " 
		   + Year + " roku")
}

function getTime(){

   var now = new Date()
   var hour = now.getHours()
   var min = now.getMinutes()
   var sec = now.getSeconds()
   if(hour<10){hour="0" + hour}
      if(min<10){min="0" + min}
      if(sec<10){sec="0" + sec}
   time.innerHTML=hour + ":" + min + ":" + sec
   setTimeout("getTime()",500)
}

</script>

Wywołanie skryptów na stronie ma postać:


<body onload="getTime()">
(...)
<script type="text/javascript">getDateStr();</script>
(...)
Aktualnie jest godzina: 
<span id="time"></span>

Natomiast nagłówek mojej strony wygląda następująco:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl">
<?xml version="1.0" encoding="iso-8859-2"?>

<head>
<link rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="Content-Language" content="pl" />
<meta name="decsription" content="Firma zajmuje się programowaniem aplikacji w różnych językach programowania" />
<meta name="keywords" content="programowanie, program, programy, AJ, języki programowania, Java, C, C++, C/C++, XHTML, XML, 
HTML, WWW, PHP, SQL, java, c, c++, c/c++, xhtml, xml, html, strony, php, sql, Flash, Perl, Python, programowanie na zlecenie, 
programy na zlecenie, program na zlecenie, zlecenie, programowanie na zamówienie, programy na zamówienie, zamówienie" />
<meta name="author" content="A&amp;J Corporation" />
<meta name="copyright" content="Copyright (c) A&amp;J Corporation" />
<meta name="language" content="pl" />
(...)

Podczas walidacji występują następujące ostrzeżenia, a po nich errors:

Line 134, Column 11: character "<" is the first character of a delimiter but occurred as data.

if(Year<=99)

This message may appear in several cases:

* You tried to include the "<" character in your page: you should escape it as "&lt;"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.

Warning Line 147, Column 10: character "<" is the first character of a delimiter but occurred as data.

if(hour<10){hour="0" + hour}

This message may appear in several cases:

* You tried to include the "<" character in your page: you should escape it as "&lt;"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.

Warning Line 148, Column 12: character "<" is the first character of a delimiter but occurred as data.

  if(min<10){min="0" + min}

This message may appear in several cases:

* You tried to include the "<" character in your page: you should escape it as "&lt;"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.

Warning Line 149, Column 12: character "<" is the first character of a delimiter but occurred as data.

  if(sec<10){sec="0" + sec}

This message may appear in several cases:

* You tried to include the "<" character in your page: you should escape it as "&lt;"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.

Error Line 5, Column 5: XML Parsing Error: XML declaration allowed only at the start of the document.

<?xml version="1.0" encoding="iso-8859-2"?>

Error Line 134, Column 12: XML Parsing Error: StartTag: invalid element name.

if(Year<=99)

Error Line 147, Column 11: XML Parsing Error: StartTag: invalid element name.

if(hour<10){hour="0" + hour}

Error Line 148, Column 13: XML Parsing Error: StartTag: invalid element name.

  if(min<10){min="0" + min}

Error Line 149, Column 13: XML Parsing Error: StartTag: invalid element name.

  if(sec<10){sec="0" + sec}

I co jest najciekawsze - podczas takiego układu nagłówka Firefox i Netscape nie widzą zegarka, a gdy część:

<!DOCTYPE html PUBLIC "-*W3C*DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

umieszczę zaraz po:

<html xmlns="http://www.w3.org/1999/xhtml" lang="pl"> <?xml version="1.0" encoding="iso-8859-2"?>

to wszystkie przeglądarki interpretują skrypt poprawnie..
Oczywiście przy takim układzie nagłówka natychmiast pojawia się błąd walidacji związany z brakeim !DOCTYPE

Z góry wielkie dzięki za wszelkie podpowiedzi :)

0

Chodzi o <. Kod JS powinieneś albo wyciągnąć do innego pliku, albo zamknąć w CDATA.

1 użytkowników online, w tym zalogowanych: 0, gości: 1