You are here: Re: converting to STRICT (href values and target attribute) « HTML « IT news, forums, messages
Re: converting to STRICT (href values and target attribute)

Posted by Joel Shepherd on 10/01/06 16:57

In article <1159665105.259688.133730@m7g2000cwm.googlegroups.com>,
petermichaux@gmail.com wrote:

> Hi,
>
> I am converting an old page to STRICT.
>
> When validating the page I learned that I can't have a link like the
> following. The '&' and '=' characters are not allowed? How can I make
> this link validate?
>
> <a
> href="http://www.foo.com/cgi-bin/test.pl?ACCOUNT=1006458&THE_BUTTON=display_pa
> ge&PAGE_TYPE=MI_PPC#ASDF">

http://www.example.com/cgi-bin/test.pl?ACCOUNT=1006458&amp;THE_BUTTON=dis
play_page&amp;PAGE_TYPE=MI_PPC#ASDF

.... Should make the validator happier.

Why? Suppose your URL looked like this instead:

http://www.example.com/cgi-bin/test.pl?ACCOUNT=1006458&COPY=2&PAGE_TYPE=M
I_PPC#ASDF

&copy is a defined character entity in HTML. The href value in a link is
CDATA, and browsers are supposed to interpret CDATA:

"CDATA is a sequence of characters from the document character set and
may include character entities. User agents should interpret attribute
values as follows:
* Replace character entities with characters,
* Ignore line feeds,
* Replace each carriage return or tab with a single space."

(http://www.w3.org/TR/html401/types.html#type-cdata)

So your browser would be strongly tempted to replace the &COPY in the
above URL with a copyright symbol character ... and that's probably not
what you want.

Use &amp; instead of & in URLs to separate parameters: browsers will
handle it properly and you'll avoid risk of unintended interpretation.

> I also learned that I can't use the "target" attribute in STRICT pages
> like the following. What do I do to get around this? Do I have to write
> JavaScript in the onclick attribute?

Yes.

> That wouldn't be so good if JavaScript is off.

True, but if the user turned it off, he/she probably knows how to open
pages in new windows/tabs/whatever anyways. If the user isn't human, it
doesn't care.

--
Joel.

 

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

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