PDA

View Full Version : Running two interstatial ads



desk2web
05-16-2010, 05:49 PM
1) Script Title: Interstitial Content Box (v1.1)

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

3) Describe problem: Firstly I have to commend the author on this script, its fantastic. My "problem" is that I would like to run 2 ads on the site - the first will (and does) open on load, one time per browser session - this works flawlessly. However, I would like to add a second ad which opens after say 2 minutes as a site survey form so that I can gauge users feelings on the site.

Is this possible? If so how - or is there some other way to achieve this.

Thanks in advance

jscheuer1
05-17-2010, 08:22 AM
Set everything up as normal for a once per session box. In the configuration set your two pages here:


var interstitialBox={
//1) list of files on server to randomly pick from and display
displayfiles: ['samplecontent.htm', 'samplecontent2.htm'],

Make the first one be the one you want shown onload, the second one the survey.

Then find these functions and make the highlighted changes:


closeit:function(){
this.interVeil.style.display="none"
this.interContainer.style.display="none"
if (this.disablescrollbars && window.XMLHttpRequest) //if disablescrollbars enabled and modern browsers- IE7, Firefox, Safari, Opera 8+ etc
this.standardbody.style.overflow="auto"
if (typeof this.timervar!="undefined") clearTimeout(this.timervar)
this.ajaxconnect(this.displayfiles[1], this.interContainer);
},


initialize:function(){
this.createcontainer() //write out interstitial container
this.ajaxconnect(this.displayfiles[0], this.interContainer) //load page into content via ajax
this.dotask(window, function(){interstitialBox.hidescrollbar(); interstitialBox.getscrollbarwidth(); setTimeout("interstitialBox.showcontainer()", 100)}, "load")
this.dotask(window, function(){interstitialBox.showcontainer()}, "resize")
}

At the very end of the script, add this code:


;(function(box){
if(!box.launch){
return;
}
setTimeout(function(){
box.hidescrollbar();
box.getscrollbarwidth();
setTimeout(function(){
box.showcontainer();
box.interVeil.style.display='';
box.interContainer.style.display='';
}, 100);
}, 60 * 2000);
})(interstitialBox);

The above will launch your first one onload, and the second after 2 minutes. Both will only be once per session.