2014年8月11日 星期一

【PHP、Jquery】廣告計數

計算一個廣告被被點擊次數有兩種狀況
1.站內廣告
原理:當點擊時用ajax計數,範例:
<a href="7311.tw" class="st-ad" adid="10"></a>

<script>
// 廣告計數
$("a.st-ad").click(function (e){
  e.preventDefault();
  $this = $(this);
  $.post("aj_ad.php",
    {mod:'ad_statistics',ad_id:$(this).attr('adid')},
    function (){
      window.location = $this.attr('href');
  });
});
</script>
2.站外廣告
原理:先連結到一頁專門計數的頁面,再轉到連結頁面

沒有留言:

張貼留言