SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member Patrick_M's Avatar
    Join Date
    Aug 2004
    Location
    Ohio
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question There Has Got To Be A Better Way To Do This...

    Hi Folks,

    I could do this better in php, but I know very little about javascript,
    can someone point my in the right direction for the following:

    Code:
         s = new String(window.location);
         s = s.replace("file:///","");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         s = s.replace("%20"," ");
         document.write(s);
    Basically, the places where my string as a space gets replaced
    with %20, and I want to remove them all. So far, this is the only
    way I've found to do that.

    Any help would be appreciated,
    Patrick

  2. #2
    SitePoint Enthusiast tuxidomasx's Avatar
    Join Date
    Feb 2007
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    s = new String(window.location);
    s= s.replace("file:///","");
    s= s.replace(/%20/g," ");
    document.write(s);
    regular expressions are your friend

    and if u wanna streamline it:
    Code:
    s = new String(window.location).replace("file:///","").replace(/%20/g," ");
    document.write(s);
    i make it rain on them hoes

  3. #3
    Non-Member Patrick_M's Avatar
    Join Date
    Aug 2004
    Location
    Ohio
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Tuxidomasx!


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
  •