Wednesday, May 31, 2006

JS querystring params when ! is the command delimiter

I faced a problem receiving the querystring params using only JS code.
Scratching the web I found examples of JS functions which rely on to retrieve the querystring, then parsing it into

This solution works well on standard URL (which Domino generates by default):¶m1=value1

This is because the would return everything after the question mark, meaning OpenDocument¶m1=value1

But what we can do when the Domino generated URL is:!OpenDocument¶m1=value1 ?

This change can be performed server-wide by setting a parameter into the server document, then all generated URL will change the question mark with the exclamation mark. And in this case, would be empty :)

My solution was something like this:

if("") {
if (document.location.href.indexOf('!') != -1) qryString = document.location.href.substring (document.location.href.indexOf('!')) ;
} else {
qryString = ;

meaning that if is empty, I search for the first ! into the location.href and assume everything after is the querystring to be searched for required parameters. Not sure if this is the best approach, though ...
Post a Comment

Disclaimer: The information in this weblog is provided "AS IS" with no warranties whatsoever, and confers no rights to any institution/person/organization. These are my personal thoughts and ideas. When I am inspired by others I give credit, I do not assume other's work and efforts. This site is NOT supported, approved, blessed etc. by Lotus Software and/or IBM Corporation.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 License.