PDA

View Full Version : Amazon style dropin box - can we add a delay?



goodfella
08-17-2008, 11:04 AM
1) Amazon style drop in box

2) http://www.dynamicdrive.com/dynamicindex17/amazondrop.htm

3) Describe problem:

I've been trying to add a time delay to this.......can anyone help please?

many thanks

jscheuer1
08-17-2008, 11:20 AM
Add this (highlighted) configuration item:


/***********************************************
* Amazon style Drop-in content box- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
* Go to http://www.dynamicdrive.com/ for full source code
***********************************************/

var dropboxleft=200 //set left position of box (in px)
var dropboxtop=100 //set top position of box (in px)
var dropspeed=15 //set speed of drop animation (larger=faster)
var dropdelay=1000 //set period of delay before drop (milliseconds, use 0 for no delay)

//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.

var displaymode="always"

///Don't edit beyond here///////////

Then in the function initboxv2, add the highlighted lines:


function initboxv2(){
if (!dom&&!ie)
return
if (dropdelay){
setTimeout(initboxv2, dropdelay);
dropdelay = 0;
return;
}
crossboxcover=(dom)?document.getElementById("dropinboxv2cover") : document.all.dropinboxv2cover
crossbox=(dom)?docume . . .

goodfella
08-17-2008, 09:32 PM
thanks for the fast response.

I've implemented as follows......but its doesn't work now. Any suggestions. Again thanks.

function initboxv2(){
if (!dom&&!ie)
return
if (dropdelay){
setTimeout(initboxv2, dropdelay);
dropdelay = 0;
return;
}
crossboxcover=(dom)?document.getElementById("dropinboxv2cover") : document.all.dropinboxv2cover
crossbox=(dom)?document.getElementById("dropinboxv2"): document.all.dropinboxv2
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossbox.height=crossbox.offsetHeight
crossboxcover.style.height=parseInt(crossbox.height)+"px"
crossbox.style.top=crossbox.height*(-1)+"px"
crossboxcover.style.left=dropboxleft+"px"
crossboxcover.style.top=dropboxtop+"px"
crossboxcover.style.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropinv2()",50)

}

jscheuer1
08-17-2008, 10:19 PM
thanks for the fast response.

I've implemented as follows......but its doesn't work now. Any suggestions. Again thanks.

function initboxv2(){
if (!dom&&!ie)
return
if (dropdelay){
setTimeout(initboxv2, dropdelay);
dropdelay = 0;
return;
}
crossboxcover=(dom)?document.getElementById("dropinboxv2cover") : document.all.dropinboxv2cover
crossbox=(dom)?document.getElementById("dropinboxv2"): document.all.dropinboxv2
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossbox.height=crossbox.offsetHeight
crossboxcover.style.height=parseInt(crossbox.height)+"px"
crossbox.style.top=crossbox.height*(-1)+"px"
crossboxcover.style.left=dropboxleft+"px"
crossboxcover.style.top=dropboxtop+"px"
crossboxcover.style.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropinv2()",50)

}

That's only the second half of my code changes. Did you institute the first section? Without both parts, that second part will only cause an error. If you have instituted both parts faithfully, then there is either some problem with my idea, or a typo/error on one or the other or both our parts. Whatever the case:

Please post a link to the page on your site that contains the problematic code so we can check it out.

I know the concept is sound. We just need to get it working for you.

Added later:

I just tested my own advice. Works fine here.

If you do follow everything I outlined, you may want to try:


var dropdelay=5000 //set period of delay before drop (milliseconds, use 0 for no delay)

for the first part. That would be a 5 second delay, so much more noticeable than the 1000 millisecond (1 second) delay my original code provides.

goodfella
08-18-2008, 09:00 PM
My apologies, I was being a dumbass.

I had set it to once per session.....and had not initiated a new session to test.

Appreciated.