I'm looking for similar function as urlencode()
from PHP just in JavaScript. jQuery library is allowed.
Basically, I need to encode the string and then redirect the user to another page just with JavaScript.
There is no function quite matching urlencode()
, but there is one quite equivalent to rawurlencode()
: encodeURIComponent()
.
Usage: var encoded = encodeURIComponent(str);
You can find a reference here:
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/encodeURIComponent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With