Ir para conteúdo
Fórum Script Brasil
  • 0

[ERRO] Validação do JS


'Tux'

Pergunta

Bom dia.. estou com o seguinte prob.

to montando um site que tem um menu dropdown.. ai coloquei um script em JS pra funcionar no IE 5 e IE 6 .. porque sem isso ele não funciona..

ele funciona normal com o JS .. porém quero validar o site no W3C .. só que dá erro no meu script JS e não valida =T

olha o código ai:

<script type="text/JavaScript">
            startList = function() 
            {        
                if (document.all&&document.getElementById) 
                {
                    navRoot = document.getElementById("nav-container");
                    for (i=0; i<navRoot.childNodes.length; i++) 
                    {
                        node = navRoot.childNodes[i];
                        if (node.nodeName=="LI") 
                        {
                            node.onmouseover=function() 
                            {
                                this.className+=" over";
                            }
                            node.onmouseout=function() 
                            {
                                this.className=this.className.replace
                                (" over", "");
                            }
                        }
                    }
                }
            }
                       window.onload=startList;
</script>
ele dá os seguintes erros na validação:
Line 20, Column 21: character "&" is the first character of a delimiter but occurred as data 
                if (document.all&&document.getElementById) 

✉ 

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.
 Line 20, Column 23: cannot generate system identifier for general entity "document.getElementById" 
                if (document.all&&document.getElementById) 

✉ 

An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs". 

Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters. 

If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem. 

Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed. 
 Line 20, Column 23: general entity "document.getElementById" not defined and no default entity 
                if (document.all&&document.getElementById) 

✉ 

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 
 Line 20, Column 46: reference not terminated by REFC delimiter 
                if (document.all&&document.getElementById) 

✉ 

If you meant to include an entity that starts with "&", then you should terminate it with ";". Another reason for this error message is that you inadvertently created an entity by failing to escape an "&" character just before this text. 
 Line 20, Column 46: reference to entity "document.getElementById" for which no system identifier could be generated 
                if (document.all&&document.getElementById) 

✉ 

This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 
 Line 20, Column 21: entity was defined here 
                if (document.all&&document.getElementById) 
 Line 23, Column 43: character ";" not allowed in attribute specification list 
                    for (i=0; i<navRoot.childNodes.length; i++) 

✉ 
 Line 23, Column 43: element "navRoot.childNodes.length" undefined 
                    for (i=0; i<navRoot.childNodes.length; i++) 

✉ 

You have used the element named above in your document, but the document type you are using does not define an element of that name. This error is often caused by: 
incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Frameset" document type to get the "<frameset>" element),
by using vendor proprietary extensions such as "<spacer>" or "<marquee>" (this is usually fixed by using CSS to achieve the desired effect instead).
by using upper-case tags in XHTML (in XHTML attributes and elements must be all lower-case).
 Line 42, Column 11: end tag for "navRoot.childNodes.length" omitted, but OMITTAG NO was specified 
        </script></head>

✉ 

You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">". 
 Line 23, Column 16: start tag was here 
                    for (i=0; i<navRoot.childNodes.length; i++) 
 Line 20, Column 21: XML Parsing Error: xmlParseEntityRef: no name 
                if (document.all&&document.getElementById) 

✉ 
 Line 20, Column 45: XML Parsing Error: EntityRef: expecting ';' 
                if (document.all&&document.getElementById) 

✉ 
 Line 23, Column 42: XML Parsing Error: error parsing attribute name 
                    for (i=0; i<navRoot.childNodes.length; i++) 

✉ 
 Line 23, Column 42: XML Parsing Error: attributes construct error 
                    for (i=0; i<navRoot.childNodes.length; i++) 

✉ 
 Line 23, Column 42: XML Parsing Error: Couldn't find end of Start Tag navRoot.childNodes.length line 23 
                    for (i=0; i<navRoot.childNodes.length; i++)

Obrigado.

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...