JavaScript Div滚动条在chrome中不起作用

时间:2012-08-22 20:40:58

标签: javascript html google-chrome scroll

我有一个JavaScript滚动条,它在IE中工作,但在Chrome中不起作用。另外,有没有办法扩展此脚本以停止或重新启动停止?它无限滚动。

JavaScript:

// JavaScript Document
var scrollspeed = "1"       // SET SCROLLER SPEED 1 = SLOWEST
var speedjump       = "30"  // ADJUST SCROLL JUMPING = RANGE 20 TO 40
var startdelay  = "2"   // START SCROLLING DELAY IN SECONDS
var nextdelay       = "5"   // SECOND SCROLL DELAY IN SECONDS 0 = QUICKEST
var topspace        = "0"       // TOP SPACING FIRST TIME SCROLLING
var frameheight = "277" // IF YOU RESIZE THE WINDOW EDIT THIS HEIGHT TO MATCH

current = (scrollspeed)

if (isIE) {     

    function HeightData(){
        AreaHeight=dataobj.offsetHeight
        if (AreaHeight==0){
            setTimeout("HeightData()",( startdelay * 1000 ))
        } else {
            ScrollNewsDiv()
        }
    }

    function NewsScrollStart(){
        dataobj=document.all? document.all.ticker :      document.getElementById("ticker")
        dataobj.style.top=topspace
        setTimeout("HeightData()",( startdelay * 1000 ))
    }

    function ScrollNewsDiv(){
        dataobj.style.top = (parseInt(dataobj.style.top) - (scrollspeed)) + "px";
        if (parseInt(dataobj.style.top)<AreaHeight*(-1)) {
            dataobj.style.top=frameheight
        setTimeout("ScrollNewsDiv()",( nextdelay * 1000 ))
        } else {
            setTimeout("ScrollNewsDiv()",speedjump)
        }
    }

    NewsScrollStart();
}

HTML:

<body onload="ScrollNewsDiv();">
<div id="ticker" style="display: block;">
    content
</div>

1 个答案:

答案 0 :(得分:0)

也许是一个天真的答案,但我会去做。

因为所有功能都以isIE为条件,因此在Chrome中可能是假的。