Insert Javascript variable into PHP return
I am sure this should be easy but I ahve been going crazy trying to get it to work:
return '<img border="0" src="'.$args['Image URL'].'?amount='.$args['invoiceAmount'].'&trans_id='.$args['invoiceNumber'].'&jrox_svalue_1=Sitename:javascript:doc开发者_开发百科ument.write (sitename);" width="1" height="1">';
Essentially I need to inject the javascript varialbe "sitename" into the querystring value (jrox_svalue_1)for the image.
jrox_svalue_1=Sitename:javascript:document.write (sitename);
Any help would be apprecaited.
This should do the trick:
<script>
document.write("<?php echo '<img border="0" src="' . $args['Image URL'] . '?amount=' . $args['invoiceAmount'] . '&trans_id=' . $args['invoiceNumber'] . '&jrox_svalue_1=' ?>" + sitename + '" width="1" height="1">');
</script>
Hope this would help
<img id="jroxImg" src="'.$args['Image URL'].'?amount='.$args['invoiceAmount'].'&trans_id='.$args['invoiceNumber']." width="1" height="1">
<script type="text/javascript">
var jroxImgObj=document.getElementById('jroxImg');
var jroxImgSrc=jroxImgObj.getAttribute('src');
jroxImgSrc+="&jrox_svalue_1="+siteName;//document.location ??
jroxImgObj.setAttribute('src',jroxImgSrc);
</script>
精彩评论