escaping '&' on the urls?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

escaping '&' on the urls?

Post by pedrotuga »

I am trying to validate my site as transitional html but i get a warning because i have a link that looks something like

http://somesite.com/somefile.php?bla=4&bloo=9

i am using Tidy firefox plugin and it sugests this:

Code: Select all

<a href="http://www.domain.com/cgi?x=123&y=456">
Good	<a href="http://www.domain.com/cgi?x=123&y=456">

All special characters in HREF should be encoded. "&" is a reserved character to begin an page.
Solution:

Replace "&" by "&".
The link points to an external site, can i replace '&' by '&amp' in the url without fearing uncorrect query string handling on the external site?
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

All ampersands in an URL which are not followed by a character entity code (I believe that's what they're called) followed by a semicolon are invalid and should be converted to the entity &
The server shouldn't have any problems with handling the URL.
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

vigge89 wrote:All ampersands in an URL which are not followed by a character entity code (I believe that's what they're called) followed by a semicolon are invalid and should be converted to the entity &
The server shouldn't have any problems with handling the URL.
thank you... i will replace them then.
Post Reply