Re: ampersand in urls when using xhtml 1.0 strict
- From: Harlan Messinger <hmessinger.removethis@xxxxxxxxxxx>
- Date: Mon, 17 Dec 2007 09:35:11 -0500
mark4asp wrote:
mark4asp wrote:
When I write a url in xhtml, with an unencoded ampersand, like this:
http://localhost:2063/Client/ViewReport.aspx?Ref=58&Type=SUMMARY
the xhtml sytax checker correctly indicates an error, telling me that
it should be:
http://localhost:2063/Client/ViewReport.aspx?Ref=58&Type=SUMMARY
see: <http://www.htmlhelp.com/tools/validator/problems.html#amp>
However the last sentence there ends:
"the browser translates "&" to "&" so the Web server would only
see "&" and not "&" in the query string of the request."
My web server is clearly seeing & and the browser (FF 1.0.0.11) is
also showing & in the url.
I am using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
with no xml prefix because, as we all know, IE6 breaks when the xml
prefix is present.
What is the cause and solution of this problem.
I am using FF 1.0.0.11, via a local asp.net 2.0 site through the mini
webserver (Cassini) on WinXP SP2 with all latest o/s updates installed
(apart from IE7, I am using IE6 on this PC).
Do I have to apply a url decode algorithm when the web page loads?
That is far from ideal because the problem here is that the browser is
not showing the decoded url.
Is this a bug in FF?
Finally is there a DOCTYPE I can use to force all the 5 major
browsers: IE6, IE7, FF, Opera, Safari to all render in strict mode
when displaying xhtml?
The immediate problem is now fixed. Somehow the page with the urls was
missing a Content-Type header:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
After including this header I was able to remove the encoded
ampersands, [ & ], to replace them with just a &. The xhtml
syntax checker no longer indicated errors here and the page navigation
now works.
First, this is very strange because if your browser was displaying the page as HTML, then it was already receiving a content type header from the web server (which the web server should always send--the META tag should only be useful for cases where the server isn't sending a content type header or when you are opening up a static web page directly on your system instead of requesting it from a web browser) telling it that the page was HTML, or else there was no header and the browser was treating it as HTML by default.
Second, this is very strange because NOT encoding ampersands *is* invalid and the W3C validator wouldn't start treating it as valid because you included a META tag that wasn't necessary anyway and that wouldn't cause the effect that you've stated.
.
- Follow-Ups:
- Re: ampersand in urls when using xhtml 1.0 strict
- From: mark4asp
- Re: ampersand in urls when using xhtml 1.0 strict
- From: Andreas Prilop
- Re: ampersand in urls when using xhtml 1.0 strict
- References:
- ampersand in urls when using xhtml 1.0 strict
- From: mark4asp
- Re: ampersand in urls when using xhtml 1.0 strict
- From: mark4asp
- ampersand in urls when using xhtml 1.0 strict
- Prev by Date: Re: ampersand in urls when using xhtml 1.0 strict
- Next by Date: Re: 100% width element causes scrollbar in IE when dir=rtl
- Previous by thread: Re: ampersand in urls when using xhtml 1.0 strict
- Next by thread: Re: ampersand in urls when using xhtml 1.0 strict
- Index(es):
Relevant Pages
|