Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Javascript Redirect



2:25 pm on May 28, 2008 (gmt 0)

5+ Year Member

I need to use Javascript to redirect and pass the incoming URL parameters to the new website.

For example, a call to:
[mywebsite...] needs to transfer to:



I have tried using
<script language="javascript"><!--

This transfers control to the desired webpage, but the parameters are not passed.


Thank you in advance for any help you can provide.


7:57 pm on May 28, 2008 (gmt 0)

10+ Year Member

You need to retrieve the parameters before being able to use them. Here's a general function that I use for doing just that.

function getURLParam(strParamName){
var strReturn = "";
var strHref = window.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?"));
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
return strReturn;

Then you can setup your redirect like this:

<script type="text/javascript">

Hope that helps and you get it figured out.


5:30 pm on May 29, 2008 (gmt 0)

5+ Year Member

Thank you very much!

With your help, I now have it working as desired.



11:50 am on May 31, 2008 (gmt 0)

5+ Year Member

Thank you very much!

Featured Threads

Hot Threads This Week

Hot Threads This Month