Thursday, January 19, 2006

Encoding "+" etc. in URL

The Javascript escape function didn't encode + ' " / £ characters. You will need to do the replacing as follows, otherwise, you won't get what you want.

function URLEncode( url)
{  
    return escape(url).replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F').replace(/\£/g,'%3A');
}

0 Comments:

Post a Comment

<< Home