handling special char e.g. "&"

G

Guest

hello how does javascript handle char like &? i have a dynamically build link
and javascript cant handle values like &? why is taht?
 
D

Derek Harmon

Asha said:
i have a dynamically build link and javascript cant handle values like &?
why is taht?

You mean a hyperlink? Hyperlinks are URL - they must be URL encoded.
Characters like '&' separate query string parameters in HTTP GET requests,
so if you have an ampersand ('&') that is not a delimiter in a query string then
the URL must URL-encode it as "%26".

So if you had a URL in the request like,

http://www.example.com/merger.aspx?acquirer=SBC&acquiree=AT&T

Then the '?' separates the endpoint on the web server,
"http://www.example.com/merger.aspx," from the query string which
contains two parameters, each separated by '&',

Name = acquirer Value = SBC
Name = acquiree Value = AT&T

Notice that when performing the URL decoding step, the '&' character
that is part of the parameter value gets converted back from "%26" to
'&'. 0x26 hex, by the way, is that character code of '&'.

Javascript includes an encode( ) function for performing these URL
encoding duties.


Derek Harmon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top