Forum Moderators: open

Message Too Old, No Replies

Iframe or Frane set auto redirect

varriable redirects from a sigle iframe

         

griddesign

10:33 am on Aug 22, 2007 (gmt 0)

10+ Year Member



I need to redirect a single iframe on one website to several different pages with another website based on multiple href links from a email.

So the rout is: email links > to one iframe to > multiple varriable web sites based on the varriables on the orriginal email links.

I am not a programmer so any help much appreciated.

I assume the orriginal links will need varriables appended to them

i.e.

[mywebsite.com?link1...]
[mywebsite.com?link2...]
[mywebsite.com?link3...]

these varriables will then be picked up by some javascript in the iframe and redirect accordinly to what ever the varriables are assigned to.

Many thanks in advance.

Trace

1:42 pm on Aug 22, 2007 (gmt 0)

10+ Year Member



In the page that creates the iframe, use this;
<script type="text/javascript">
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];
break;
}
}
}
return strReturn;
}

switch(getURLParam('link')*1)
{
case 1:
document.write('<iframe src="http://www.site1.com"></iframe>');
break;
case 2:
document.write('<iframe src="http://www.site2.com"></iframe>');
break;
default:
document.write('<iframe src="http://www.site3.com"></iframe>');
}
</script>

And your links need to look like this;

http://www.example.com?link=1
http://www.example.com?link=2
http://www.example.com?link=3

I haven't actually tried it but it should work.