任何人都知道如何在标头标记中插入此代码?

我使用Yii Framework。

通过我的阅读可以使用CClientScript完成

<!-- Facebook Conversion Code for cashout -->
<script type="text/javascript">
var fb_param = {};
fb_param.pixel_id = 'XXXX';
fb_param.value = '0.00';
fb_param.currency = 'MYR';
(function(){
var fpw = document.createElement('script');
fpw.async = true;
fpw.src = '//connect.facebook.net/en_US/fp.js';
var ref = document.getElementsByTagName('script')[0];
ref.parentNode.insertBefore(fpw, ref);
})();
</script>
<noscript><img height="1" width="1" alt="" style="display:none"     src="facebook.com/offsite_event.php?id=XXXX&amp;value=0&amp;currency=MYR" /></noscript>


提前致谢

最佳答案

您可以将其放置在视图中的任何位置,但如果这样做,它将仅在该位置可用

如果要让yii处理,可以这样

Yii::app()->clientScript->registerScript('myCustomScript', "

var fb_param = {};
fb_param.pixel_id = 'XXXX';
fb_param.value = '0.00';
fb_param.currency = 'MYR';
(function(){
  var fpw = document.createElement('script');
  fpw.async = true;
  fpw.src = '//connect.facebook.net/en_US/fp.js';
  var ref = document.getElementsByTagName('script')[0];
  ref.parentNode.insertBefore(fpw, ref);
})();

");

08-07 01:51