|
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&THE_BUTTON=dis
play_page&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©=2&PAGE_TYPE=M
I_PPC#ASDF
© 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 © in the
above URL with a copyright symbol character ... and that's probably not
what you want.
Use & 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.
[Back to original message]
|