Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grab Paramater from URL

Status
Not open for further replies.

dontpunchme

Programmer
Jul 29, 2002
20
US
Hi,

I have a new website that I am launching. I want to redirect users who came to my old site via a 3rd party search box to my new site with the same parameter. BTW the 3rd party box is out of my control.

Current URL that comes in when a user searches via the 3rd party search box:
www.mydomain.com?searchterm=camera&uid=56012

want to redirect to
www.mynewdomain.com?sterm=camera&user=jjj&referrer=900


Need to do using Javascript/Html only.

Thanks for your help.
 
This should do what you want:

Code:
<script language="javascript">
<!--
var big_parts = document.location.href.split("?");

// if there's a parameter section
if (big_parts.length == 2) {
    var sets = big_parts[1].split("&");
	alert(sets[0]);
	// loop through query string, looking for "searchterm"
	for (var i = 0; i < sets.length; i++) {
        var singles = sets[i].split("=");
		if (singles[0] == 'searchterm')
		    var the_val = singles[1];
	}
    alert(the_val);
	var the_url = '[URL unfurl="true"]http://www.yourdomain.com/page.html?sterm='[/URL] + the_val + '&user=jjj&referrer=900';
	document.location = the_url;
}

-->
</script>

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top