Return to Snippet

Revision: 6543
at May 29, 2008 05:49 by IanLewis


Initial Code
function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
                                     
    var ret = str;
    
    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');
 
    return ret;
}

Initial URL
http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_urlencode/

Initial Description

                                

Initial Title
Javascript urlencode

Initial Tags
url

Initial Language
JavaScript