求助!只要打开/查看其他标签就会出错的JS!
时间:2011-10-29
来源:互联网
DEMO :
http://yqjun.tk/demo/html/scrollTextDiv.html
JS部分代码
JScript code
function InfoBox(containerId) { this.oContainer = document.getElementById(containerId); this.oaInfoBox = this.oContainer.getElementsByTagName("li"); this.autoTimer = this.changeHeightTimer = this.changeOpacityTimer = null; } InfoBox.prototype = { init: function() { this.autoScroll(); }, listenToMouse: function() { }, autoScroll: function() { var self = this; this.autoTimer = setInterval(function() { self.toggle(); }, 3000); }, toggle: function() { var endIndex = this.oaInfoBox.length - 1; var lastLi = this.oaInfoBox[endIndex]; this.oContainer.insertBefore(lastLi, this.oContainer.firstChild); var targetHeight = this.oaInfoBox[0].offsetHeight; this.oaInfoBox[0].style.height = 0 + "px"; this.oaInfoBox[0].style.opacity = "0"; this.oaInfoBox[0].style.filter = "alpha(opacity=0)"; this.changeHeight(targetHeight); }, changeHeight: function(targetHeight){ var self = this; var speed = newHeight = 0; clearInterval(self.changeHeightTimer); this.changeHeightTimer = setInterval(function() { speed = (targetHeight - newHeight) / 8; newHeight += speed; self.oaInfoBox[0].style.height = newHeight + "px"; //test begin var span = document.getElementById("test"); span.innerHTML = "speed: " + speed + " / targetHeight : " + targetHeight +" / height: " + newHeight; //test end if(speed <= 0.1) { self.oaInfoBox[0].style.height = targetHeight + "px"; self.showDiv(); clearInterval(self.changeHeightTimer); } }, 30); }, showDiv: function() { var self = this; var argOpacity = 0; clearInterval(this.changeOpacityTimer); this.changeOpacityTimer = setInterval(function(){ argOpacity += 5; self.oaInfoBox[0].style.opacity = argOpacity / 100; self.oaInfoBox[0].style.filter = "alpha(opacity=" + argOpacity +")"; if(argOpacity >= 100) { clearInterval(self.changeOpacityTimer); } }, 30); } }
作者: yqjun123 发布时间: 2011-10-29

帮顶,lz这个问题遇到过.后来换其他方法.
作者: jayrao5566 发布时间: 2011-10-29
作者: KongHuLu 发布时间: 2011-10-29
是当前窗体时,继续执行.
试试..
作者: jayrao5566 发布时间: 2011-10-29
难道是传说中的don't blink?
作者: KongHuLu 发布时间: 2011-10-29
IE无此现象,是跟渲染有关?
作者: KongHuLu 发布时间: 2011-10-29
试了试只有webkit内核的浏览器会出现。
IE无此现象,是跟渲染有关?
对 safari 这样的webkit内核不会出现这样的情况.火狐就会出现..
作者: jayrao5566 发布时间: 2011-10-29
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28