Results 1 to 5 of 5

Thread: Drop-in content box

  1. #1
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Drop-in content box

    Code:
    <!-- POP UP BOX -->
    <script language="JavaScript1.2">
    
    // Drop-in content box- By Dynamic Drive
    // For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
    // This credit MUST stay intact for use
    
    var ie=document.all
    var dom=document.getElementById
    var ns4=document.layers
    var calunits=document.layers? "" : "px"
    
    var bouncelimit=32 //(must be divisible by 8)
    var direction="up"
    
    function initbox(){
    if (!dom&&!ie&&!ns4)
    return
    crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    crossobj.top=scroll_top-250+calunits
    crossobj.visibility=(dom||ie)? "visible" : "show"
    dropstart=setInterval("dropin()",50)
    }
    
    function dropin(){
    scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
    if (parseInt(crossobj.top)<100+scroll_top)
    crossobj.top=parseInt(crossobj.top)+40+calunits
    else{
    clearInterval(dropstart)
    bouncestart=setInterval("bouncein()",50)
    }
    }
    
    function bouncein(){
    crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
    if (bouncelimit<0)
    bouncelimit+=8
    bouncelimit=bouncelimit*-1
    if (bouncelimit==0){
    clearInterval(bouncestart)
    }
    }
    
    function dismissbox(){
    if (window.bouncestart) clearInterval(bouncestart)
    crossobj.visibility="hidden"
    }
    
    function truebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    
    window.onload=initbox
    
    </script>
    
    <!-- END POP UP BOX -->
    and the cod in the body

    Code:
    <!-- POP UP BOX BODY CONTENT -->
    <div id="dropin" style="position:absolute; visibility:hidden; left:80px; top:693px; width:504px; height:249px;">
    
    <table width="500" height="245" border="0" cellpadding="2" background="whatever.gif" class="popuptable">
    <tr valign="top">
                        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
    What ever content you want to pop out her
      
                    </table>
    
    <!-- END POP UP BOX BODY CONTENT -->
    Is there a way to make this script pop out if a person leaves my page instead when they come to my page?

    If this script can't be modified for this purpose, is there any other one here i can use that can pop out like this one but only when a person leaves the page?

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Code:
    window.onload=initbox
    Change highlighed above to: window.onbeforeunload
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The actually didn't do anything. It just stopped the popup. And on firefox it kind of shows half way on the top and goes away. Would you have a script i could use, that pops up on exit for fire fox and ie and safari.

  4. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    I'm sorry, but I'm on my wits end. The only thing I could think of is to prompt for a user interaction, possibly as Yes or No:
    Code:
    window.onbeforeunload=function(){return 'Do you really want to leave this page?';}
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I think using an alert message to physically halt the unloading of the current page as Rangana has proposed is about the only way to display the Drop In Content box when the user is just about to leave the page.

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
  •