Posted By

jquery4u on 06/02/11


Tagged

jquery


Versions (?)

jQuery Encode/Decode URL String


 / Published in: JavaScript
 

URL: http://www.jquery4u.com/snippets/jquery-decode-url-string/

  1. var url = $(location).attr('href'); //get current url
  2. //OR
  3. var url = 'folder/index.html?param=#23dd&noob=yes'; //or specify one
  4.  
  5. var encodedUrl = encodeURIComponent(url);
  6. console.log(encodedUrl);
  7. //outputs folder%2Findex.html%3Fparam%3D%2323dd%26noob%3Dyes

Report this snippet  

You need to login to post a comment.