Is it possible to encode a URL in JavaScript?

I learned in PHP to encode a URL and send it using GET method. Is it possible to do the same in JavaScript?

ex.
var url1 = www.someurl.com/?name=ben&membershipno=54875

I want to encode this and then send it as a GET parameter of another URL.

Comments

  • var yourOtherURL = "http://yoursite.com/index.html?url=" + encodeURIComponent(url1);

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion