Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ghall

macrumors 68040
Original poster
Jun 27, 2006
3,771
1
Rhode Island
Hi. I was wondering if there was some code to rotate web content, such as ads. If so, where can I get it?
 
Try google, there is Javascript code to allow you to have an image change after a certain time, or theres one that will display a random images, or ad each time the page is refreshed.

Depends what you want, just try googling.
 
I'm not a fan of using Javascript unless it's absolutely necessary. When possible, I prefer to do these things server-side. Search engines like me better for it. :)

Here's a way to do this in ColdFusion:

HTML:
<cfset pickQ1 = '#randrange(1,4)#' />

<cfif #pickQ1# EQ "1">

<img src="ad1.jpg" />

<cfelseif #pickQ1# EQ "2">

<img src="ad2.jpg" />

<cfelseif #pickQ1# EQ "3">

<img src="ad3.jpg" />

<cfelse>

<img src="ad4.jpg" />

</cfif>

I lost my code for doing this in PHP. Sorry. :(
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.