PDA

View Full Version : Interstitial Script Activated by button or link?



homersheineken
12-20-2012, 10:11 PM
Interstitial Content Box
http://www.dynamicdrive.com/dynamicindex17/interstitial.htm

Is there a way for the interstitial script to only be activated by the user via a button or link?

Thx!

ddadmin
12-21-2012, 01:03 AM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

vwphillips
12-22-2012, 06:22 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
.popup{
position: absolute;visibility:hidden;padding: 15px;padding-top: 0;background-color: #d0e47e;border: 1px solid black;z-index: 6;
width: 670px; /*Width of popup*/
}

.popup .headerbar{ /*CSS for header bar of popup*/
position:relative;color: gray;padding: 5px 0;height:30px;text-align:left;font-size: 20px;
}


.popup .headerbar IMG { /*CSS for header bar image of popup*/
position:absolute;left:650px;top:5px;
}

.content { /*CSS for div that holds the content to show*/
border: 1px solid gray;background-color: white;
}

.mask{ /*CSS for background mask*/
position:fixed;background-Color: black;width:100%;height:100%;left:0px;top:0px;z-index: 5;filter:progid:DXImageTransform.Microsoft.alpha(opacity=80);opacity: 0.8;
}

/*]]>*/
</style>
</head>

<body>
for pop1<br />
<input type="button" name="" value="Display pop 2" onmouseup="zxcSplashPopUp.Display('pop1');"/>
<input type="button" name="" value="Ajax File 1" onmouseup="zxcSplashPopUp.Ajax('pop1','http://www.dynamicdrive.com/dynamicindex17/samplecontent.htm');"/>
<input type="button" name="" value="Ajax File 2" onmouseup="zxcSplashPopUp.Ajax('pop1','http://www.dynamicdrive.com/dynamicindex17/samplecontent2.htm');"/>
<input type="button" name="" value="HTML" onmouseup="zxcSplashPopUp.HTML('pop1','http://www.dynamicdrive.com/dynamicindex17/samplecontent2.htm');"/>
<br />
<br />
for pop 2<br />
<input type="button" name="" value="Display pop 2" onmouseup="zxcSplashPopUp.Display('pop2');"/>
<input type="button" name="" value="Ajax File 1" onmouseup="zxcSplashPopUp.Ajax('pop2','http://www.dynamicdrive.com/dynamicindex17/samplecontent.htm');"/>
<input type="button" name="" value="Ajax File 2" onmouseup="zxcSplashPopUp.Ajax('pop2','http://www.dynamicdrive.com/dynamicindex17/samplecontent2.htm');"/>
<input type="button" name="" value="HTML" onmouseup="zxcSplashPopUp.HTML('pop2','http://www.dynamicdrive.com/dynamicindex17/samplecontent2.htm');"/>

<div id="pop1" class="popup" >
<div class="headerbar" >
pop 1 <img src="http://www.vicsjavascripts.org.uk/StdImages/Exit1.gif" style="border: 0" title="Close Box" onmouseup="zxcSplashPopUp.Hide('pop1');" />
</div>
</div>

<div id="pop2" class="popup" style="background-Color:#FFFFCC;" >
<div class="headerbar">
pop 2 <img src="http://www.vicsjavascripts.org.uk/StdImages/Exit1.gif" style="border: 0" title="Close Box" onmouseup="zxcSplashPopUp.Hide('pop1');" />
</div>
<div id="content2" class="content" >
some text<br />
some text<br />
</div>
</div>
<script> vic=0; </script>
<form name=Show id=Show style="position:absolute;visibility:visible;top:700px;left:0px;" >
<input size=100 name=Show0 >
<input size=10 name=Show1 >
<input size=10 name=Show2 >
<input size=10 name=Show3 >
<input size=10 name=Show4 >
<input size=10 name=Show5 >
<input size=10 name=Show6 >
<input size=10 name=Show7 >
<input size=10 name=Show8 >
<input size=10 name=Show9 ><br>
<textarea name=TA rows=1 cols=100 ></textarea>
</form>

<script type="text/javascript">
/*<![CDATA[*/
// SplashPopUp. (22-December-2012)
// by Vic Phillips - http://www.vicsjavascripts.org.uk/

var zxcSplashPopUp={

init:function(o){
var id=o.ID,ccls=o.ContentClass,mcls=o.MaskClass,ajax=o.AjaxFile,f=o.DisplayFrequency,ms=o.AnimateDuration,days=o.DaysPersistence,pop=document.getElementById(id),di v=document.createElement('DIV'),msk=div.cloneNode(false),ccls=typeof(ccls)=='string'?ccls:false,days=typeof(days)=='string'?days:-1,nu;
if (ccls){
div.className=ccls;
pop.appendChild(div);
}
pop.style.overflow='hidden';
msk.className=mcls;
msk.style.position='fixed';
msk.style.visibility='hidden';
msk.style.left='0px';
msk.style.top='0px';
msk.style.width='100%';
msk.style.height='100%';
msk.appendChild(pop);
document.body.appendChild(msk);
o=zxcSplashPopUp['zxc'+id]={
id:id,
msk:msk,
pop:pop,
div:ccls?div:document.getElementById(o.ContentID),
ms:typeof(ms)=='number'&&ms>0?ms:false,
days:days
}
f=typeof(f)=='number'&&(Math.round(Math.random()*f)==0||this.cookie(id+'=')=='true');
if (o.div&&typeof(ajax)=='object'&&ajax.constructor==Array){
nu=Math.floor(Math.random()*ajax.length);
if (typeof(ajax[nu])=='string'){
o.ajax=ajax[nu];
this.ajax(o,o.ajax,f);
}
}
if (!o.ajax&&f){
this.ready(o);
}
this.pop=o;
this.addevt(msk,'mousedown','Hide',id);
},

Hide:function(id,e){
var o=zxcSplashPopUp['zxc'+id],obj;
if (o){
if (e){
obj=e.target?e.target:e.srcElement;
while (obj.parentNode){
if (obj==o.pop){
return;
}
obj=obj.parentNode;
}
}
if (o.ms){
clearTimeout(o.dly);
this.animate(o,'height',o.pop.offsetHeight,0,new Date(),o.ms);
}
else {
this.hide(o);
}
this.cookieset(o,false);
}
},

Ajax:function(id,url){
var o=zxcSplashPopUp['zxc'+id];
if (o&&o.div&&typeof(url)=='string'){
if (o.ajax&&o.ajax.substring(url.lastIndexOf('/')+1)==url.substring(url.lastIndexOf('/')+1)){
this.ready(o);
}
else {
o.ajax=url;
this.ajax(o,url);
}
}
},

HTML:function(id,html){
var o=zxcSplashPopUp['zxc'+id];
if (o&&o.div&&typeof(html)=='string'){
o.ajax='';
o.div.innerHTML=html;
this.ready(o);
}
},

Display:function(id){
var o=zxcSplashPopUp['zxc'+id];
if (o){
this.ready(o);
}
},

ready:function(o){
if (o!=this.pop){
this.hide(this.pop);
}
o.pop.style.left=(o.msk.offsetWidth-o.pop.offsetWidth)/2+'px';
o.pop.style.top=(o.msk.offsetHeight-o.pop.offsetHeight)/2+'px';
this.pop=o;
if (o.ms){
clearTimeout(o.dly);
this.animate(o,'height',0,o.pop.offsetHeight,new Date(),o.ms);
}
o.msk.style.visibility=o.pop.style.visibility='visible';
this.cookieset(o,true);
},

animate:function(o,mde,f,t,srt,mS){
var oop=this,ms=new Date().getTime()-srt,now=(t-f)/mS*ms+f;
if (isFinite(now)){
o.pop.style[mde]=Math.max(now,0)+'px';
}
if (ms<mS){
o.dly=setTimeout(function(){ oop.animate(o,mde,f,t,srt,mS); },10);
}
else {
o.pop.style[mde]=t+'px';
if (t==0&&mde=='height'){
this.hide(o);
}
}
},

hide:function(o){
clearTimeout(o.dly);
o.msk.style.visibility=o.pop.style.visibility='hidden';
o.pop.style.height='auto';
},

addevt:function(o,t,f,p){
var oop=this;
if (o.addEventListener){
o.addEventListener(t,function(e){ return oop[f](p,e);}, false);
}
else if (o.attachEvent){
o.attachEvent('on'+t,function(e){ return oop[f](p,e); });
}
},

cookie:function(nme){
var re=new RegExp(nme+'[^;]+','i');
if (document.cookie.match(re)){
return document.cookie.match(re)[0].split("=")[1];
}
return null
},

cookieset:function(o,ud){
document.cookie=o.id+'='+ud+';expires='+(new Date(new Date().getTime()+o.days*86400000).toGMTString())+';path=/';
},

ajax:function(o,url,f){
var oop=this,html=false;
if (window.ActiveXObject){
try {
html=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
html=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
}
}
}
else if (window.XMLHttpRequest){
html=new XMLHttpRequest();
}
else {
return false;
}
html.onreadystatechange=function(){ oop.ajaxpopulate(o,html,f); }
html.open('GET',url+'?'+new Date().getTime(),true);
try {
html.send(null);
}
catch (e){
}
},

ajaxpopulate:function(o,html,f){
if (html.readyState==4&&(html.status==200||window.location.href.indexOf("http")==-1)){
html=html.responseText;
if (o&&html){
o.div.innerHTML=html;
if (f){
this.ready(o);
}
}
}
}

}

zxcSplashPopUp.init({
ID:'pop1', // the unique ID name of the Pop Up DIV. (string)
ContentClass:'content', //(optional) the class name of the Pop Up content DIV. (string, default = ContentID or the PopUp DIV HTML)
ContentID:null, //(optional) the unique ID name of the Pop Up content DIV. (string, default = ContentClass or the PopUp DIV HTML)
MaskClass:'mask', //(optional) the class name of the Pop Up mask DIV. (string, default = no mask)
DisplayFrequency:1, //(optional) the display on initialisation frequency, 0 = always. (number, default = no display on initialisation)
AjaxFile:[ //(optional) display a ajax random file from the array on initialisation. (array, default = the PopUp DIV HTML)
'http://www.dynamicdrive.com/dynamicindex17/samplecontent.htm','http://www.dynamicdrive.com/dynamicindex17/samplecontent2.htm'
],
AnimateDuration:1000, //(optional) the animation speed in milli seconds. (number, default = no animation)
DaysPersistence:-1 //(optional) number = the number of days to restore the pop up. (number, default = -1 = no persistence)
});

zxcSplashPopUp.init({
ID:'pop2', // the unique ID name of the Pop Up DIV. (string)
ContentID:'content2', // the unique ID name of the Pop Up content DIV. (string)
AnimateDuration:1000 // the animation speed in milli seconds. (number, default = no animation)
});

/*]]>*/
</script>

</body>

</html>