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).