Forum Moderators: open
First what I am trying to do is to grab a url query and write it to the links on the landing page so if any of the links get clicked on the query goes with it.
There are a few query grabbing links around but I can not get them to write to the page.
Here is an example:
visitor comes to my site from this link:
www.domain.com?id=1234
The page they land on has several links on it:
faq.html?(i_want_the_id_inserted_here 1234)
benefits.html?(i_want_the_id_inserted_here 1234)
help.html?(i_want_the_id_inserted_here 1234)
etc.
Below are a few scripts I was trying to work with but I was hoping someone could add to them so they would write to my links as I demonstrated above.
<script type="text/javascript">
querystring = location.search.substring(1);
</script>
if (location.search.length > 0) {
launchString = location.search.substring(1, location.search.length);
var launchStringArray = launchString.split("&");
for (var i = 0; i <= launchStringArray.length - 1; i++) {
var left = launchStringArray[i].substring(0, launchStringArray[i].indexOf("="));
var right = launchStringArray[i].substring(launchStringArray[i].indexOf("=") + 1, launchString.length);
if (isNaN(right)) {
right = '"' + right + '"';
}
eval("var " + left + " = " + right);
}
}
I have tried with no success so I hope someone is in the charity mood and can figure this out.
Thanks for any help
John
</HEAD>
<BODY>
<script language="javascript">
function linkWithQuery(url,txt)
{
return "<a href=\"" + url + location.search + "\">" + txt + "</a>"
} // linkWithQuery
</script>
<script language="javascript">
document.write(linkWithQuery("http://www.yahoo.com/more.html","<img src='/images/select.gif' border='0' alt='Select'>"))
</script>