Results 1 to 6 of 6

Thread: Amazon style dropbox delay option?

  1. #1
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Amazon style dropbox delay option?

    Hi all, been lurking on site for about two weeks so please be gentle with my virgin post

    Quick (and probably pathetically simple) question to ask about the Amazon Style Drop Box script....

    http://www.dynamicdrive.com/dynamici...amazondrop.htm

    How would I put a delay on this box so that it delayed say 5 seconds before dropping down on the visitor?

    TIA

  2. #2
    Join Date
    Dec 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well it says right in the code - drop down speed. The larger the number the faster it drops. I would try a small number...ya think?

  3. #3
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeh, I tried that, but then it just drops down really slow, not really the desired effect.

    I probably wasn't clear enough. I want it to drop down after the page has been opened for say 5 seconds.

    I'm thinking maybe a setTimeout type function, but I'm way too green to be attempting this myself.

    Any other suggestions maybe?

  4. #4
    Join Date
    Dec 2004
    Posts
    177
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default

    Exactly. There was a little bug in just switching the onloads to setTimeout, so I took a redundant, but effective route. Here is everything in the <script> tags, keep the styles and div from the original code. To change the delay now, change the value of timeDelay, keeping in mind it uses milliseconds.

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * 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 timeDelay=5000 //How long before dropping (in millisec)
    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)
    
    //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///////////
    
    if (parseInt(displaymode)!=NaN)
    var random_num=Math.floor(Math.random()*displaymode)
    var ie=document.all
    var dom=document.getElementById
    
    function initboxv2(){
    if (!dom&&!ie)
    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)
    }
    
    function dropinv2(){
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    if (parseInt(crossbox.style.top)<0){
    crossboxcover.style.top=scroll_top+dropboxtop+"px"
    crossbox.style.top=parseInt(crossbox.style.top)+dropspeed+"px"
    }
    else{
    clearInterval(dropstart)
    crossbox.style.top=0
    }
    }
    
    function dismissboxv2(){
    if (window.dropstart) clearInterval(dropstart)
    crossboxcover.style.visibility="hidden"
    }
    
    function truebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = ""
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) {
    offset += search.length
    end = document.cookie.indexOf(";", offset)
    if (end == -1)
    end = document.cookie.length;
    returnvalue=unescape(document.cookie.substring(offset, end))
    }
    }
    return returnvalue;
    }
    
    function myDelay(){
     setTimeout(initboxv2, timeDelay)
    }
    
    if (displaymode=="oncepersession" && get_cookie("droppedinv2")=="" || displaymode=="always" || parseInt(displaymode)!=NaN && random_num==0){
    if (window.addEventListener)
    window.addEventListener("load", myDelay, false)
    else if (window.attachEvent)
    window.attachEvent("onload", myDelay)
    else if (document.getElementById || document.all)
    window.onload=myDelay
    if (displaymode=="oncepersession")
    document.cookie="droppedinv2=yes"
    }
    
    </script>

  5. #5
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Apologies for delay and bandwidth wasting, but THANK YOU!

    Worked a treat.



  6. #6
    Join Date
    Aug 2006
    Location
    Oregon
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can the box only open once per year?

    I too needed to delay the box timing & it works Great! Can the box be set every 365 days?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •