p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

proasp_howto thread: How do you 'URL Encode' in client side JavaScript

Message #1 by Darren Wogan <darrenw@s...> on Fri, 23 Jun 2000 11:29:29 +0100
Hi there,

Try escape (strMessage). I guess this does what you need.
To reverse the process, I think there is an unescape (strMessage) as well.


At 11:29 6/23/2000 +0100, you wrote:
>I have a client side JavaScript string which I want to URL Encode, to
>include it as part of a URL address.
>The string may contain spaces and a number of other non-URL friendly
>characters (e.g. '\').
>I know there is an ASP function to do this, Server.URLEncode(string).
>However how do you do this in client side JavaScript, e.g. :
>        // message to be encoded
>         msg = "Some Example Message which might state e.g. a path (e.g.
>'c:\new path')"
>         // Call new page to display the message
>         newURL = "/arm/LogClientMsg.asp?msg="
>         // presumably a function exists to encode it, e.g.:
>         newURL += msg.encodeToURL()
>         // then go to new page with this string
>         location.href = newURL
>P.S. I know that I could submit a form , however that is not ideal in this
>situation. Surely I don't need to use 'replace()' for every special
>Darren Wogan

  Return to Index