Jump to content
  • 0

Валидация


theo_
 Share

Question

Хочется узнать по поводу валидности кода...

DOCTYPE - XHTML 1.0 Transitional

из php файла вывожу прямо в body

echo '<script type="text/javascript">

$(function() {

$("body").append("<div id=\''.$sub_about_id.'\' class=\'menu_sub\'></div>");

});

</script>';

Так вот при проверке валидатором выдается ошибка -

document type does not allow element "div" here

$("body").append("<div id='about_div' class='menu_sub'></div>");

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

также ошибка выдается когда в js-коде идет проверка условия (&&)

ругается на эти символы....

character "&" is the first character of a delimiter but occurred as data

if ((!in_about_div)&&(!show_about_div)) {

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.

Подскажите как от этого избавиться?

Вынести js-код в отдельный файл сложновато в моем случае...

Link to comment
Share on other sites

3 answers to this question

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy