SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript equivalent of URLEncode -- not escape()

    Does anyone have a work around in javascript that will produce the same results as the VBScript functions URLEncode() and URLDecode().

    I am aware of the javascript escape() and unescape() functions, however this does not produce the results i am looking for. For example, if I have a quotation mark ("), the javascript escape() will render this as %22 (or something like that) whereas the URLEncode will render this as &-quot; (had to insert the hyphen because i can't fugure out how to get vbulletin to not represent it like this ") I know that I could write a regex for every single character somebody could put in there but i didn't know if anyone else had come across and solved this problem in a different way.

    Thanks!
    Last edited by makeda; Oct 15, 2002 at 09:04.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    javascript only has the escape() and unescape() functions for these purposes.

    Note: the way to get the forum to display your characters correctly, is to create the ampersand first, then follow with the rest..

    like this

    "

    gives you this result..

    "
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For sure, as soon as I think something is for sure, I learn something to the contrary

    You can also use eval()
    or
    encodeURI(), which is only available in Javascript 1.5

    I haven't tested these to see how they differ....let me know your results
    Last edited by beetle; Oct 22, 2002 at 21:30.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •