<a onclick="go_url(ENCODED-URL);return false;">go to this url</a>
Asked
Active
Viewed 201 times
1
-
3Can 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 Answers
2
Use decodeURI()
and encodeURI()
.
The
decodeURI()
function decodes a URI encoded with theencodeURI()
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
-
thanks for the edit, the URI version are what you want. escape/unescape encodes for display – Byron Whitlock Sep 30 '09 at 22:50
-
Aye. I did a roll-back on your answer (was confused there for a second) and added my edits to my own. – cllpse Sep 30 '09 at 22:53
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
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