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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to pass parameters to an URL inside an i-frame

Status
Not open for further replies.

fpl9250

Programmer
Jan 22, 2007
46
US
Hello,

I have the script below to extract the parameters in the parent window URL but I need to paste them onto the URL that will be called from an i-frame. Can somebody tell me the syntax to build the new URL for this i-frame?

this is the code to extract the parameters

Code:
function addCampParam ( endUrl )
{
var mc_id_param = gup( 'WT.mc_id' );
var acctnum_param = gup( 'acctnum' );

var cmpltUrl = endUrl + "&WT.mc_id=" + mc_id_param + "&acctnum=" + acctnum_param + "&WT.mc_ev=ContentClick";

window.location = cmpltUrl;

}

function gup( name )
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}
 
[1] Suppose your iframe is scripted like this.
[tt]
<iframe name="x" id="y" src="">iframe support needed</iframe>
[/tt]
[2] You could replace this line:
[tt] >[/tt]window.location = cmpltUrl;

[2.a] by either
[tt] window.frames["x"].location = cmpltUrl;[/tt]

[2.b] or
[tt] document.getElementById("y").src = cmpltUrl;[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top