You are here: Re: Closing tags within <script></script> « HTML « IT news, forums, messages
Re: Closing tags within <script></script>

Posted by Michael Winter on 10/13/06 17:32

Jeffrey wrote:

[snip]

> alert("<script>function foo() { alert("Hello!"); }</script>");

You cannot nest quotation marks like that. You either need to escape the
inner pair, or change one of them to single quotes (').

[snip]

> According to this page, I should expect this behavior because ending
> HTML tags are not allowed to appear within <script> tags:
> http://www.htmlhelp.com/tools/validator/problems.html#script

Indeed, though more precisely, there can be no ETAGO (</) tokens
followed by a NAME character (that is, anything that looks like an
end-tag). This is because a HTML parser will be looking for these when
trying to find the end of the element; it doesn't need to look for an
end-tag that matches the start-tag because some end-tags are optional
whilst others are forbidden.

The document you cite tells you how to avoid the problem: escape the
backslash to break apart the ETAGO (<\/).

> But my problem is that some very popular websites, seem to violate
> this ...

Popular websites often do stupid things, but the sheer weight of their
popularity often means that they can get away with it. It's not
something to emulate though, if anyone was thinking along those lines.

[snip]

Mike

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация