|
Posted by The KwikOne on July 22, 2008, 5:01 pm
Please log in for more thread options > .oO(The KwikOne)
>
> >Since to have a page validate (HTML and XHTML) you should have your
> >URL parameters separated by the appropriate separator. However, if an
> >ampersand is used it needs to be expressed as & (example: ./
> >index.php?a=3D1&B=3D2).
>
> You only do this if the URL is printed to an HTML page, for example in
> an 'a' element:
>
> <a href=3D"./?a=3D1&B=3D2">foo</a>
>
> BTW: Don't write "index.html" or "index.php" in URLs, it's not necessary
> and bad style.
>
> >But, if that is done, then the _GET or
> >_REQUEST array element names are incorrect.
>
> No. The & is interpreted by the browser, the server will never see
> it if you click that link.
>
> >In the example the _GET
> >array will be:
> >_GET['amp;a'] =3D 1 (instead of _GET['a'] =3D 1) and _GET['amp;B'] =3D 2
> >(instead of _GET['B'] =3D 2).
>
> >So, how do I get around this?
>
> There's a bug somewhere in your code. Can you post a short code example
> or page snippet which causes this problem? How does the final HTML code
> for such a link look? Do you see something like
>
> <a href=3D"./?a=3D1&amp;B=3D2">foo</a>
>
> Notice the "double-encoding" of the ampersand. This could be one reason
> for your problem.
>
> >Is there any other way other than
> >looping and stripping the 'amp;' part prior to actually looking for
> >parameters? What do others do in this situation?
>
> Nothing, because it shouldn't happen.
>
> Micha
Micha,
Actually I found that this problem only occurred when doing a
window.open in javascript;
such as window.open('/x.php?a=3D1&b=3DB', etc);
So, I have found my workaround (personally I think it is a bug within
javascript in Firefox v3
since it did not seem to see failures when IE v7 was used).
So, instead of window.open('/x.php?a=3D1&b=3DB', etc);
I now have it as: window.open('/x.php?a=3D1&'+'b=3DB', etc);
and it works OK and validation does not fail.
|