Re: Error Message Feedback

On Tue, Aug 08, 2006 at 09:47:02AM +0100, Neil Smith wrote:
> This was discussed last week - technically it's incorrect to have the
> closing angle bracket inside your javascript string.

No, closing angle brackets are fine. Opening angle brackets cause
problems, as do ampersands.

> You could reasonably use the decimal character entity <
> instead. 

That is an opening angle bracket, but it will cause problems for XHTML
served as HTML (since <script> elements implicitly contain CDATA in
HTML documents).

> Many people now enclose script blocks in CDATA sections,
> i.e.  http://www.w3schools.com/xml/xml_cdata.asp
 
> <![CDATA[
> <script language="javascript" type="text/javascript">

The script element should contain CDATA, it shouldn't me marked as
CDATA itself - otherwise browsers (treating the XHTML as XHTML rather
than broken HTML) will render the entire script element as text!

You also need to take steps so that the CDATA isn't treated as
JavaScript if the document is served as HTML.

The XHTML spec has suggestions on dealing with this. I just avoid
XHTML on the client side except in situations where it provides a real
benefit (which, so far, with the content I write, has been never).

> A better solution is to tell PHP to use XHTML compatible argmuent
> separators 

The requirement is not restricted to XHTML, it applies to HTML too.

> (it's actually a bug in PHP's default setting on some versions).

On some versions? When did they fix it? Last time I looked at the bug
I got the impression that the developers were convinced that
generating correct HTML by default would break people's scripts.

> You're not sending it what "normal" user agents would see

Rejecting cookies isn't /that/ unusual.

-- 
David Dorward                                      http://dorward.me.uk

Received on Tuesday, 8 August 2006 09:08:28 UTC