jQuery Encode/Decode URL String


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.