PDA

View Full Version : Random Content (for ad banners)



edk012
10-10-2006, 04:06 PM
1) Script Title: Random Content Order script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/randomcontentorder.htm

3) Describe problem: I'm trying to put advertisting in my website and thought that this script would be helpful to randomize the banner that is displayed. Only problem is it randomizes the order of multiple content. Is there a variation of this script that will work for my needs?

Thanks!

jscheuer1
10-10-2006, 04:25 PM
http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm

edk012
10-10-2006, 04:36 PM
Thanks!

edk012
10-10-2006, 04:50 PM
okay. not working and I can't figure out why. here is the exact code I have inserted on the page. any suggestions?

<script language="JavaScript1.2">

//Random iframe content- &#169; Dynamic Drive (www.dynamicdrive.com)
//For full source code, and Terms Of use, visit http://dynamicdrive.com
//This credit MUST stay intact for use

var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1

//Specify IFRAME display attributes
var iframeprops='width=468 height=60 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'

//Specify random URLs to display inside iframe
var randomcontent=new Array()
randomcontent[0]="<a href="http://click.linksynergy.com/fs-bin/click?id=G5s9fB6V01s&offerid=47167.10000454&type=4&subid=0"><IMG alt="HearthSong" border="0" src="http://www.hearthsong.com/assets/images/hearthsong/images/affiliates/HS468x60-fall05-text.gif"></a><IMG border="0" width="1" height="1" src="http://ad.linksynergy.com/fs-bin/show?id=G5s9fB6V01s&bids=47167.10000454&type=4&subid=0">"
randomcontent[1]="<A HREF="http://click.linksynergy.com/fs-bin/click?id=G5s9fB6V01s&offerid=88128.10000020&type=4&subid=0"><img src="http://www.homefocusaffiliates.com/images/home/home_468x60.gif" WIDTH=468 HEIGHT=60 border=0></A><IMG border=0 width=1 height=1 src=http://ad.linksynergy.com/fs-bin/show?id=G5s9fB6V01s&bids=88128.10000020&type=4&subid=0>"
randomcontent[2]="<a href="http://click.linksynergy.com/fs-bin/click?id=G5s9fB6V01s&offerid=115554.10000031&type=4&subid=0"><IMG alt="LEGO Shop at Home" border="0" src="http://cache.lego.com/2057/images/shop/Affiliate/LEGO_SAH_468x60.gif"></a><IMG border="0" width="1" height="1" src="http://ad.linksynergy.com/fs-bin/show?id=G5s9fB6V01s&bids=115554.10000031&type=4&subid=0">"

//No need to edit after here
if (ie||dom)
document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')

function random_iframe(){
if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
}
}

window.onload=random_iframe

</script>

edk012
10-10-2006, 08:09 PM
I think the problem could be that there are two images trying to be loaded. One is the banner ad image, and the other is a 1x1 pixel image that is used for impression tracking. Let me know if it's possible to keep the impression tracking image.

jscheuer1
10-11-2006, 04:31 PM
In this part (from the demo):


//Specify random URLs to display inside iframe
var randomcontent=new Array()
randomcontent[0]="random1.htm"
randomcontent[1]="random2.htm"
randomcontent[2]="random3.htm"
randomcontent[3]="random4.htm"

You need to specify a page, not HTML code as you have done. If you make up a page, one for each of your banners, you can include whatever you want on each of those pages.