homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Javascript Redirect

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

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)

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)

Thank you very much!

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



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

Thank you very much!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved