polmsted
10-28-2003, 01:21 PM
I was wondering if anyone could help me.... I have found some code that will Parse out the URL if the link has ?blah=blah&blah=blah on it. I don't know how to encorporate that code so that it adds it onto a link so if the person goes to another page within the site, the ?blah=blah&blah=blah will stay with the url?
Here is the code I found to parse the URL:
<head>
<script>
function parseUrl()
{
var i, pos, argname, value, queryString, pairs;
// get the string following the question mark
queryString = location.search.substring(1);
// split parameters into pairs, assuming pairs are separated by ampersands
pairs = queryString.split("&");
// for each pair, we get the name and the value
for (i = 0; i < pairs.length; i++)
{
pos = pairs[i].indexOf('=');
if (pos == -1)
{
continue;
}
argname = pairs[i].substring(0,pos);
value = pairs[i].substring(pos+1);
alert("argname is " + argname + " and value is " + value);
}
}
</script>
</head>
<body onload="parseUrl();">
All I know is that I need to create a javascript link that if will attach the argname and value if it is there to the end of an href link so that those values remain. It is so we can track sponsors. Any way you can help?
Thank You,
Skip
Here is the code I found to parse the URL:
<head>
<script>
function parseUrl()
{
var i, pos, argname, value, queryString, pairs;
// get the string following the question mark
queryString = location.search.substring(1);
// split parameters into pairs, assuming pairs are separated by ampersands
pairs = queryString.split("&");
// for each pair, we get the name and the value
for (i = 0; i < pairs.length; i++)
{
pos = pairs[i].indexOf('=');
if (pos == -1)
{
continue;
}
argname = pairs[i].substring(0,pos);
value = pairs[i].substring(pos+1);
alert("argname is " + argname + " and value is " + value);
}
}
</script>
</head>
<body onload="parseUrl();">
All I know is that I need to create a javascript link that if will attach the argname and value if it is there to the end of an href link so that those values remain. It is so we can track sponsors. Any way you can help?
Thank You,
Skip