5 / 5
Oct 2008

Hi there,



I am trying to fix the JS on my thank you page (hosted on my server) that brings in the thank you page for the download link, here is my current JS:



<script language="javascript" type="text/javascript">

document.write("'<iframe src=https://www.e-junkie.com/ecom/rp.php?noredirect=true&txnid=' + 'TxnID' + 'width=100%' + 'height=50px'")

</script>



Which is not working. TxnID is the variable for the transaction ID takn from the URL. This functionality is 100% working as I am writing it to the page elsewhere.



It is the Syntax that writes my Iframe that is not working.



I appreciate this is a problem with my knowledge o JS, not a problem with E Junkie, but all the same I would really apprecite if anyone could wade in and show me the correct JS Syntax,



Thanks in advance



Richard

  • created

    Oct '08
  • last reply

    Oct '08
  • 4

    replies

  • 1.1k

    views

  • 3

    users

  • 4

    links

Can you please post the URL of the page where we can check this?

Hi there,



thank you for the reply. I dont want to post the link, but I can post the relevant code below.



The script is currently working fine in Firefox but not in Safari. I haven't Tested in other browsers yet. I think the problem is that Safari is not writing "" around the src url for the Iframe.



---------------------------------



<h1>Thank you for your order</h1>

<div class="clear"></div>



<script language="javascript" type="text/javascript">

function getParameter( parameterName ) {

var queryString = window.location.search.substring(1);

var parameters = queryString.split('&');

for(var i = 0; i < parameters.length; i++) {

if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {

var parameterValue = parameters[i].split('=');

return parameterValue[1];

}

}

return '[not supplied]';

}

var FirstName = getParameter('first_name');

var LastName = getParameter('last_name');

var PayerEmail = getParameter('payer_email');

var PayerEmailEsc = unescape(PayerEmail);

var TxnID = getParameter('txn_id');

var Status = getParameter('payment_status');





</script>







<div class="box-generic-editorial light">



<h2>Your Download Link</h2>



<script language="javascript" type="text/javascript">

document.write('<iframe src=https://www.e-junkie.com/ecom/rp.php?noredirect=true&txnid=' + TxnID + ' width=100%' + ' height=50px' + ' /></iframe>')

</script>



</div>



--------------------------



Code after here writes the variables from the URL into the page and is irrelevant to the problem at hand.

I'm no JavaScript wizard personally, so I'm not sure what the issue could be with the JS you presented; however, the following is some functional iFrame JS that another Merchant had devised for their own use and posted on their blog for others' benefit, so perhaps you could use, adapt, or learn something from it:



---



<script type="text/javascript">

<!--

function gup( name )

{

name = name.replace(/[[]/,"\[").replace(/[\]]/,"\]");

var regexS = "[\?&]"+name+"=([^&#]*)";

var regex = new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results == null )

return "";

else

return results[1];

}

document.write("<iframe src=http://www.e-junkie.com/ecom/rp.php?noredirect=true&txnid="+gup('txn_id')+" style='width:100%;'></iframe>");

// -->

</script>



---



BTW, note that everything from document.write... to ...</iframe>"); there should actually be strung out on one long line together (apologies for the line-breakage here).

Tyson, thanks very much.



I havent tried the JS that you posted but I have got my own JS (taken from various sources) to work. I'll post it below for anyone to use so that it might save some future headaches.



I make no comment about which JS is better, though yours does look leaner.



Richard



JS, Thank you page, Download link in iframe, variables from URL using JS, Transaction ID



----------------------------------



<h1>Thank you for your order</h1>



<script language="javascript" type="text/javascript">

function getParameter( parameterName ) {

var queryString = window.location.search.substring(1);

var parameters = queryString.split('&');

for(var i = 0; i < parameters.length; i++) {

if (parameters[i].indexOf(parameterName.toLowerCase())>=0) {

var parameterValue = parameters[i].split('=');

return parameterValue[1];

}

}

return '[not supplied]';

}

var FirstName = getParameter('first_name');

var LastName = getParameter('last_name');

var PayerEmail = getParameter('payer_email');

var PayerEmailEsc = unescape(PayerEmail);

var TxnID = getParameter('txn_id');

var Status = getParameter('payment_status');



</script>



<div>



<h2>Your Download Link</h2>



<iframe id="download_link" name="download_link" width="100%" height="50"> </iframe>



<script language="javascript" type="text/javascript">

var src = "https://www.e-junkie.com/ecom/rp.php?noredirect=true&txnid=" + TxnID;

document.getElementById('download_link').src = src;

</script>



</div>