RE: ampersands as literal characters in a URL?

Aha, Bjoern's solution works! Testing the escaped ampersand by typing the
URI into the web browser destination doesn't work, but setting it inside a
<A HREF=> tag does.

Thank you for the solution to my problem. I'll try it in a number of other
places and report back if I encounter any problems (hopefully I won't).

Regards - Tony Rees

-----Original Message-----
From: Bjoern Hoehrmann [mailto:derhoermi@gmx.net]
Sent: 02 October, 2001 12:50 PM
To: Tony.Rees@csiro.au
Cc: www-html@w3.org
Subject: Re: ampersands as literal characters in a URL?


* Tony.Rees@csiro.au wrote:
>Bjoern Hoehrmann <derhoermi@gmx.net> wrote:
>
>>  You have to distinguish between URIs and attribute values,
>>  <a href='script?a=1&amp;b=2'>...</a> really works on almost
>>  all browsers. The URI is still script?a=1&b=2 but with
>>  characters that must be escaped escaped. Not escaping the
>>  ampersand may cause major problems.
>
>Well, here's an example of what fails on my system, using either IE 5.00 or
>Netscape 4.72 on my PC:
>
>http://aqua.hba.marine.csiro.au:7272/CAAB/search/caab_search.search_prepare
?
>scitxt=con&amp;ctg=37
>
>whereas this works as intended:
>
>http://aqua.hba.marine.csiro.au:7272/CAAB/search/caab_search.search_prepare
?
>scitxt=con&ctg=37
>
>How is it for you?

Hm, I guess you didn't use <a
href='http://aqua.hba.marine.csiro.au:7272/CAAB/search/caab_search.search_pr
epare?scitxt=con&amp;ctg=37'>...</a>
but tried the URI instead. You have to escape the ampersand in the href
attribute, not in the URI itself.
-- 
Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/

Received on Tuesday, 2 October 2001 00:25:17 UTC