Programming
JavaScript: Decode URL (online example + source)
by admin on May.25, 2011, under Programming
The following sample form will allow you to encode and decode URLs using java script:
Source code:
<script type='text/javascript'> function encode() { document.getElementById('textArea').value = encodeURIComponent(document.getElementById('textArea').value); } function decode() { document.getElementById('textArea').value = decodeURIComponent(document.getElementById('textArea').value.replace(/\+/g, " ")); } </script>
Don’t forget to replace textArea with the ID of your text area.
The above code is similar to the PHP function urldecode.