Search This Blog

Google Analytics

Wednesday, June 06, 2007

JavaScript How To Get QueryString

Below is written by my EE friend, ryancys. Happen to see this piece of code (posted in Experts-Exchange) and so might as well post it here. Below JavaScript function will return the value part of a querystring given the named value.

function querystring(name) // returns a named value from the querystring yourpage.html?xyz=123
    var tmp =;
    var i = tmp.toUpperCase().indexOf(name.toUpperCase()+"=");

    if (i>= 0)
        tmp = tmp.substring(name.length+i+1);
        i = tmp.indexOf("&");
        return unescape(tmp = tmp.substring(0,(i>=0) ? i : tmp.length));


Edited on 10 Nov 2007: The post was made by respected expert ryancys but original author is someone else.

No comments:

Post a Comment

Do provide your constructive comment. I appreciate that.

Popular Posts