Adding a link to a page using the Querystring content in javascript

Posted: November 16, 2009 in javascript, QueryString

Below is the code to create a link in a page which includes some value from the querystring of the current page.

<script>
var qsParm = new Array();
function qs()
{
     var query = window.location.search.substring(1);
     var parms = query.split('&');
     for (var i=0; i<parms.length; i++)

    {
         var pos = parms[i].indexOf('=');
         if (pos > 0)

        {
             var key = parms[i].substring(0,pos);

             var val = parms[i].substring(pos+1);
             qsParm[key] = val;
        }
    }
}
qsParm['ID'] = null;
qs();
var addressTr= "Technical%20View.aspx?ID=" +  qsParm['ID'] ;
document.write('<a target="_self" href="' + addressTr + '">Technical View</a>');
</script>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s