龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

setInterval在ff与gg浏览器下奇怪现象

时间:2012-12-29 08:41来源:未知 作者:admin 点击:
分享到:
文章讲述一下关于setInterval函数在ie,ff和chrome下产生不同的效果,有时可用有时不可能,有需要的朋友参考一下。 代码如下 div id=move style=position: absolute; width: 100px; height: 100px; top: 0pt; le
文章讲述一下关于setInterval函数在ie,ff和chrome下产生不同的效果,有时可用有时不可能,有需要的朋友参考一下。

 

 代码如下

<div id="move" style="position: absolute; width: 100px; height: 100px; top: 0pt; left: 0pt; background: none repeat scroll 0% 0% #000000; z-index: 999; color: #ffffff;">我不受浏览器标签切换影响!Hoooo</div>
<div id="move2" style="position: absolute; width: 100px; height: 100px; top: 0pt; left: 0pt; background: none repeat scroll 0% 0% red; z-index: 999; color: #ffffff;">我受浏览器标签切换影响!5555</div>

js放下面


(function(){
var elem = Meng.getId('move'),
elem2 = Meng.getId('move2'),
pos = Meng.getElemViewPosition(elem),
view = Meng.getBrowserView(),
//灰块运动函数
move = function(){
var t1 = Meng.animate(elem,{top:0,left:0},{top:view.height-100,left:view.width-100},3000,function(){
var t2 = Meng.animate(elem,{left:view.width-100},{left:100-view.width},3000,function(){
var t3 = Meng.animate(elem,{top:view.height-100},{top:100-view.height},3000,function(){
move();//确定t3运动完后,我再回调move()函数。
});
});
});
};
move();
// 红块运动函数
Meng.setStyle(elem2,{top:0,left:(view.width-100)+'px'});
var move2 = function(){
var t1 = Meng.animate(elem2,{top:0,left:view.width-100},{top:view.height-100,left:100-view.width},3000,function(){
var t2 = Meng.animate(elem2,{top:view.height-100},{top:100-view.height},3000,function(){
var t3 = Meng.animate(elem2,{left:0},{left:view.width-100},3000,function(){
});
});
});
};
move2();
setInterval(function(){move2();},9050);
// 红块运动函数
})();


精彩图集

赞助商链接