[XHTML] Du code Javascript qui ne passe pas en validation XHTML !
# Warning Line 142, Column 54: character "&" is the first character of a delimiter but occurred as data .
Code:
if((a.getAttribute("rel").indexOf("style") != -1) && (a.getAttribute("title"))) {
✉
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.
# Warning Line 142, Column 55: character "&" is the first character of a delimiter but occurred as data .
Code:
if((a.getAttribute("rel").indexOf("style") != -1) && (a.getAttribute("title"))) {
✉
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.
Quand je passe les && en & pour passer la validation le code javascript évidemment ne marche plus. Que faire ?
J'ai inclus dans ma page XHTML le fichier calendar.php qui contient le code javascript. (phpcollab)
Voici la fonction concernée.
Code:
1 2 3 4 5 6 7 8 9 10 11
| function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if((a.getAttribute("rel").indexOf("style") != -1) && (a.getAttribute("title"))) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
document.getElementById("style").innerHTML = title;
return false;
} |