PDA

View Full Version : Drop-in content box



jinso
07-31-2008, 10:49 AM
<!-- 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


<!-- 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?

rangana
07-31-2008, 11:21 AM
window.onload=initbox


Change highlighed above to: window.onbeforeunload

jinso
07-31-2008, 12:37 PM
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.

rangana
08-01-2008, 01:18 AM
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:


window.onbeforeunload=function(){return 'Do you really want to leave this page?';}

ddadmin
08-01-2008, 04:44 AM
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.