1月4号首页LOGO很特别<img src=/logos/newton09-tree.jpg width=384 height=138 border=0 alt="艾萨克牛顿" title="艾萨克牛顿" id=logo style="margin-top:-1.22em" onload="window.lol&&lol();setTimeout(function(){var h=0,v=1,f=document.getElementById('fall'),i=setInterval(function(){if(f){var r=parseInt(f.style.right)+h,b=parseInt(f.style.bottom)-v;f.style.right=r+'px';f.style.bottom=b+'px';if(b>-210){v+=2}else{h=(v>9)?v*0.1:0;v*=(v>9)?-0.3:0}}},25);google.rein&&google.rein.push(function(){clearInterval(i);h=0;v=1})},2000)"></a><img id="fall" src="/logos/newton09-apple.png" style="position:relative;right:248px;bottom:46px"/><noscript><style>#fall{bottom:-210px!important}</style></noscript>
以上代码没看明白 哪位给说说?
以上代码没看明白 哪位给说说?
1 setTimeout 页面打开后2秒 苹果下落开始
2 setInterval 每间隔25毫秒执行 下落 f.style.right=r+'px'; //横坐标
f.style.bottom=b+'px';//纵坐标
if(b>-210){
//下落
v+=2
} else{
//反弹
h=(v>9)?v*0.1:0
v*=(v>9)?-0.3:0
}
v<9 h=0 v=0 落地完成
var h=0,v=1,
f=document.getElementById('fall'),
i=setInterval(
function()
{if(f){
var r=parseInt(f.style.right)+h,
b=parseInt(f.style.bottom)-v;
f.style.right=r+'px';
f.style.bottom=b+'px';
if(b>-210)
{v+=2
}
else
{
h=(v>9)?v*0.1:0;
v*=(v>9)?-0.3:0;
}
}},1);
google.rein&&google.rein.push(function(){clearInterval(i);h=0;v=1;})
},1000)
这个数学好点的应该都可以做的来 还可以呵呵 其实就是通过一些公式运算数字然后通过运算结果影响坐标来实现位移的
<script language="javascript">
var h=0,v=1;
setTimeout(aa(),2000);
function aa()
{
var i=self.setInterval("bb()",25);
}function bb()
{
var f=document.getElementById('fall');
var r=parseInt(f.style.right)+h;
var b=parseInt(f.style.bottom)-v;
f.style.right=r+'px';
f.style.bottom=b+'px';
if(b>-210){
v+=2;
}else{
h=(v>9)?v*0.1:0;
v*=(v>9)?-0.3:0;
} }
</script>
<body>
<div id="fall" style="position:relative;right:-300px;bottom:46px">
apple
</div>
</body>
</html>
window.lol && lol();
setTimeout(
function() {
var h = 0, v = 1, f = document.getElementById('fall'),
i = setInterval(
function() {
if (f) {
var r = parseInt(f.style.right) + h, b = parseInt(f.style.bottom) - v;
f.style.right = r + 'px';
f.style.bottom = b + 'px';
if (b > -210) {
v += 2
}
else {
h = (v > 9) ? v * 0.1 : 0; v *= (v > 9) ? -0.3 : 0
}
}
}, 25);
}, 2000)
} 参见http://www.cnblogs.com/gudao119/archive/2010/01/04/1638668.html