te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Reload Adsense ads, or have to use DFP? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Reload Adsense ads, or have to use DFP? - Stack Overflow

programmeradmin3浏览0评论

I've found a number of sites that explain how to make a DFP ad reload/refresh after 30-120 seconds, but none of them explain if it's possible to do with an Adsense ad.

I've tried DFP - it's very confusing pared to Adsense.

My current Adsense code:

<script async src="//pagead2.googlesyndication/pagead/js/adsbygoogle.js"></script>
<!-- MYSITE- Responsive - #1 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-123456789..."
     data-ad-slot="123456789"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

I've found a number of sites that explain how to make a DFP ad reload/refresh after 30-120 seconds, but none of them explain if it's possible to do with an Adsense ad.

I've tried DFP - it's very confusing pared to Adsense.

My current Adsense code:

<script async src="//pagead2.googlesyndication./pagead/js/adsbygoogle.js"></script>
<!-- MYSITE- Responsive - #1 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-123456789..."
     data-ad-slot="123456789"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Share Improve this question asked May 18, 2015 at 2:22 DaveDave 29.1k26 gold badges115 silver badges184 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

AdSense's TOS disallow the sort of automatic refreshing you're referring to. This does not mean that you cannot automatically refresh AdSense Tags programmatically. It does mean that you will almost certainly get banned for doing so.

On the other hand, this behavior is allowed when using AdSense + Doubleclick for publishers (DFP). This documentation should point you in the right direction, and you'd want to call something like this to refresh your ads:

googletag.pubads().refresh();

The following tutorials should give you enough information to figure out how to use AdSense + DFP:

  1. General Tutorial #1 (Outdated, but still useful)
  2. General Tutorial #2 (Also outdated, but useful nonetheless)
  3. Linking AdSense + DFP (This doesn't work if you're using DFP for Small Business; instead, you'll just want to add you Adsense embed code as a third-party creative

If you are adamant about automatically refreshing ads without DFP, you could do the following wrapped in a timer function:

document.getElementById('FrameID').contentWindow.location.reload(true);

Be advised: This will get you banned from AdSense if you are not using the service through DFP

Add this code after the start <head> tag

<script async src=”//pagead2.googlesyndication./pagead/js/adsbygoogle.js”></script>
<script src=’http://connect.kyowal./kp_dev/developer/refresh.js’ type=’text/javascript’/>
<script>
var adsenceblockone = ‘<ins class=’adsbygoogle’ data-ad-client=’ca-pub-1385863686986530′ data-ad-format=’auto’ data-ad-slot=’5134528809′ style=’display:block’/>‘;
</script>

Place this code where you want to show your ads on page

<div id=”adsrefreshone”></div>
<script>
adsencerefreshone();
</script>

This code will work only for one advertisement

if you like to show more ads Read the full post here http://www.kyowal./rsiwal/posts/8702

发布评论

评论列表(0)

  1. 暂无评论