Ad rotation for PHP site & AdSense
I am looking for an ad rotation system that I can use w/ Google adsense. I have a roughly 520x240 space that I would like to rotate 7-8 adsense ads through. It would be nice if I could find a solution with smooth looking ad rotation animation. Anybody doin开发者_JS百科g anything like this?
Thank!
Rotating AdSense ad units on a page is probably a violation of the AdSense Program Policies, specifically "Direct user attention to the ads using arrows or other graphical gimmicks." It could jeopardize your account.
Besides, what would be the point of rotating the ad units in the first place? The same ads would show, because the content of the page isn't changing.
Why don't you use jQuery?
First you call the new ad by making an AJAX call to a small file containing your Adsense code. Once loaded you fadeOut the old ad and fadeIn the new ad.
If you recall this function after a specific amount of seconds, you can keep rotating your ads very easily!
I have done something similar, but using Jquery to do the transition for database tables written in php. Should be easy enough just edit this code and have everything work correctly for what you want to do with the adsense. The rotation is utilized with the content within the div tags. Good luck
<!-- include jQuery library -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<!-- include Cycle plugin -->
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"></script>
<!-- initialize the slideshow when the DOM is ready -->
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
timeout:12000
});
$("#activities").load("../includes/activities.php");
var refreshId = setInterval(function() {
$("#activities").load('../includes/activities.php');
}, 9000);
$("#troubletickets").load("../includes/tickets.php");
var refreshId = setInterval(function() {
$("#troubletickets").load('../includes/tickets.php');
}, 9000);
$("#projects").load("../includes/projects.php");
var refreshId = setInterval(function() {
$("#projects").load('../includes/projects.php');
}, 9000);
});
</script>
<LINK REL=StyleSheet HREF="../css/style.css" TYPE="text/css">
</head>
<body>
<div class="slideshow">
<div id="troubletickets"></div>
<div id="activities"></div>
<div id="projects"></div>
</div>
</body>
</html>
精彩评论