[thelist] JS: Token replacement

.jeff jeff at members.evolt.org
Wed Jan 22 12:19:01 CST 2003


joshua,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Joshua Olson
>
> I am looking for the most foolproof JavaScript code that
> allows me to replace tokens within a query string.  It
> needs to work something like this:
>
> qs_replace('http://www.domain.com?foo=bar', 'foo', 'bar2');
>
> That would return:
>
> http://www.domain.com?foo=bar2
>
> Other cases it would need to handle:
>
> 1.  Passing the third parameter as the blank string
>     should remove the token.
> 2.  If the token specified by parameter 2 is not already
>     in the url, it should be added.
> 3.  It should be able to handle cases when the ? is not
>     already appended to the string.
>
> Anybody seen a really good implementation of this type
> of function?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

should it perform a location change to make the necessary changes when you
call the qs_replace() function each time or should there be another function
that actually tells the system to take all the changes made and perform a
location change with the new query string?

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list