It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Ball drop on page load

Ball drop on page load

Postby maheswari on Mon Nov 02, 2009 9:21 am

while loading the page image is going to bounce like when ball is dropped.For ie functionality is working i need the code to work fine for all browsers
code which is working is IE

<%--<div id="ball" style="visibility: visible; position: absolute; left: 100; top: 10;
">
<img src="Images/Buy2Get1M-Box2FreeShipping.jpg" alt="Bouncing ball"
height="100" style="width: 259px" /><br />
</div>
<script type="text/Javascript">

iter = 0;
setId = 0;
down = true;
up = false;
var ns = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 4));
ie = !ns;
bouncingBall = document.getElementById("ball").style;

var winH;


if (ns)
document.captureEvents(Event.mouseup);


function buttonUp() {
winH = (ns) ? window.innerHeight - 400 + window.scrollY : document.body.offsetHeight -400+ document.body.scrollTop;

if (setId != 0) clearInterval(setId);
bouncingBall.visibility = "visible";

bouncingBall.left = (ns) ? e.pageX - 15 : 600;
bouncingBall.top = (ns) ? e.pageY - 15 : 200 + document.body.scrollTop;
iter = 0;
setId = setInterval("generateGravity()", 20);
return true;
}


function generateGravity() {
if ((parseInt(bouncingBall.top) + iter < winH) && down) {
bouncingBall.top = parseInt(bouncingBall.top) + iter;
iter++;
return;
}
else {
if ((parseInt(bouncingBall.top) < winH) && down) {
bouncingBall.top = winH + 5;
return;
}
down = false;
up = true;
if (iter < 0 && parseInt(bouncingBall.top) > winH) {
clearInterval(setId);
bouncingBall.visibility = "hidden";

setId = 0;
}
if (parseInt(bouncingBall.top) > 0 && up && iter >= 0) {
bouncingBall.top = parseInt(bouncingBall.top) - iter;
iter--;
if (iter % 3 == 0) iter--;
return;
}
down = true;
up = false;
}

}

</script>
maheswari
 
Posts: 1
Joined: Mon Nov 02, 2009 9:15 am

Re: Ball drop on page load

Postby gun5 on Tue Nov 10, 2009 6:11 pm

Code: Select all
<script type="text/javascript">
window.onload=function(){
   buttonUp(this);
}
function buttonUp(e) {
   e = e || event;


Sortable List Game Trainer
gun5
 
Posts: 3
Joined: Tue Nov 10, 2009 5:11 pm


Who is online

Users browsing this forum: No registered users and 4 guests