View Single Post
Old 09-17-2012, 09:57 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,185
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Code:
<script type="text/javascript">
var querystring = [];
if ( location.search > 1 )
{
    var temp = location.search.substring(1).split("&");
    for ( var t = 0; t < temp.length; ++t )
    {
        var pair = temp[t].split(".");
        querystring[ pair[0] ] = decodeURIComponent( pair[1] );
    }
}
// at this point the variable querystring contains all the key/value pairs from the passed-in query string.
// for example, if the URL was xxx?foo=bar&glomp=the%20widget
// then the querystring variable will consist of
//        qs["foo"] == "bar"
//        qs["glomp"] == "the widget"
//
// to get all the name/pair combinations out of querystring you could do, for example:
for ( var name in querystring )
{
    document.write( name + "==" + qs[name] + "<br/>" );
}
// though please don't really use document.write.
Doing this with jQuery would actually be MORE complex than the plain vanilla JavaScript shown above.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
algross (09-20-2012)