Encoding a URL.

Puneet20884
Posted by Puneet20884 under JavaScript category on | Views : 1818
Encoding a URL javascript can be done by the usage of its inbuilt function

encodeURI()

we need to encode sometimes the URL that the javscript doesn't take.
So to encode a URL we need to use this function,
the simple code goes as:

document.write(encodeURI('gr8 puneet.aspx?pra=tål&pcar=great'));

the output will be

gr8%20puneet.aspx?pra=t%C3%A5l&pcar=great

Comments or Responses

Login to post response