1
<a onclick="go_url(ENCODED-URL);return false;">go to this url</a>
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
  • 3
    Can you provide more detail to explain why you want to do this? What level of security is needed? What are you trying to achieve? For what reason can you not leave the URL encoded? – Dave Gamble Sep 30 '09 at 22:30

4 Answers4

2

Use decodeURI() and encodeURI().

The decodeURI() function decodes a URI encoded with the encodeURI() function.

The encodeURI() function encodes a string as a URI.

Unlike escape() and unescape() these functions are specifically designed to handle URI-encoding/decoding.

cllpse
  • 21,396
  • 37
  • 131
  • 170
0

You mean something like this?

<script type="text/javascript">

function go_url(url) {
   var u = '';
   for (var i = 0; i < url.length; i++) {
      u += String.fromCharCode(url.charCodeAt(i) ^ 7);
   }
   window.location.href = u;
}

</script>

<a href="#" onclick="go_url('ossw=((ppp)`raaf)dhj');return false;">yeah</a>
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
-1

encodeURI(ENCODED-URL);

ScottKoon
  • 3,483
  • 6
  • 27
  • 29
-1

Well you can use escape() and unescape().

cllpse
  • 21,396
  • 37
  • 131
  • 170
Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
  • escape and unescape should not be used. See also http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent – Mike Samuel Oct 01 '09 at 00:01