javascript thread: FW: [proasp_howto] How do you 'URL Encode' in client side JavaScr-ipt
Koen's right, this is probably the easiest approach. Little consolation to
you, if you don't happen to have a copy, but "Professional JavaScript",
ISBN 186100270 describes how to do almost exactly what you're asking about
on page 417 (using the escape() function, as Koen says).
On 06/23/00, "Van Tolhuyzen Koen wrote:
> try using the 'escape' command
Koen
-----Original Message-----
From: Darren Wogan
To: How To
Sent: 23/06/00 12:29
Subject: [proasp_howto] How do you 'URL Encode' in client side
JavaScript
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
character?!
Darren Wogan
---