Javascript连续滚动程序-页面刷新时加速

Javascript连续滚动程序-页面刷新时加速,javascript,continuous,ticker,Javascript,Continuous,Ticker,我有一个javascript数据记录器,我正试图在IBMCognos中实现它。我在网上找到了一些代码,其中我对我的设置做了一些更改。在页面加载时,股票代码以一种速度滚动,但在页面刷新时,股票代码会加速。我正在努力解决这个问题 为了让我的ticker在ibmcognos内部工作,我在包含变量数据的table对象周围添加了代码块。在页面加载时,表中的数据显示当月的数据,但是用户可以选择他们希望看到的数据的每日视图-使数据集变小(因此页面刷新中的数据变少) 下面的代码显示了我到目前为止所做的工作,尽管

我有一个javascript数据记录器,我正试图在IBMCognos中实现它。我在网上找到了一些代码,其中我对我的设置做了一些更改。在页面加载时,股票代码以一种速度滚动,但在页面刷新时,股票代码会加速。我正在努力解决这个问题

为了让我的ticker在ibmcognos内部工作,我在包含变量数据的table对象周围添加了代码块。在页面加载时,表中的数据显示当月的数据,但是用户可以选择他们希望看到的数据的每日视图-使数据集变小(因此页面刷新中的数据变少)

下面的代码显示了我到目前为止所做的工作,尽管它说的是“测试,测试”,这就是我将代码包装在变量表中的地方

我的目标是让股票以连续的速度滚动,即使在重新加载页面之后也是如此

我感谢你的反馈!以下是我目前的代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">

#marqueecontainer{
position: relative;
width: 1020px; /*marquee width */
height: 23px; /*marquee height */
background-color:#FFF;
color:black;
overflow: hidden;
border: 1px #FFF;
padding: 2px;
padding-left: 4px;
text-align:left;
}

#marqueecontainer img {
border-width:2px;
border-style:solid;
}

</style>

<script type="text/javascript">

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?


var copyspeed=marqueespeed // marqueespeed = 1
var pausespeed=(pauseit==0)? copyspeed: 0 // if pauseit = 0 then pausespeed = copyspeed if not then pausespeed = 0
var actualwidth='' // actualwidth is undefined

var cross_marque;
var cross_marque2;

var Start = 1

function scrollmarquee(){
if (parseInt(cross_marquee.style.left)<(actualwidth*(-1)+4))
cross_marquee.style.left=(parseInt(cross_marquee2.style.left)+actualwidth+4)+"px"
if (parseInt(cross_marquee2.style.left)<(actualwidth*(-1)+4))
cross_marquee2.style.left=(parseInt(cross_marquee.style.left)+actualwidth+4)+"px"
cross_marquee2.style.left=parseInt(cross_marquee2.style.left)-copyspeed+"px"
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee2=document.getElementById("vmarquee2")
cross_marquee.style.left=0
//marqueewidth=document.getElementById("marqueecontainer").offsetWidth 
actualwidth=cross_marquee.firstChild.offsetWidth    
cross_marquee2.style.left=actualwidth+4+'px'
cross_marquee2.innerHTML=cross_marquee.innerHTML
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

function Scroll(){
if(Start==1)
{initializemarquee();}
else
{Start=0;}
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee

</script>
</head> 

<body onload=Scroll();>

<div style="overflow:hidden">
<div id="marqueecontainer" onMouseover="copyspeed=pausespeed;"  onMouseout="copyspeed=marqueespeed;"> <span id="vmarquee" style="position: absolute; width: 98%;"><nobr>
 <!--SCROLL CONTENT HERE--> 
<table >
<tr>
<td nowrap>
testing testing testing
</td>
</tr>
</table>
</nobr></span><span id="vmarquee2" style="position: absolute; width: 98%;"></span></div> </div>
</body>

#马奎尔集装箱{
位置:相对位置;
宽度:1020px;/*选框宽度*/
高度:23px;/*选框高度*/
背景色:#FFF;
颜色:黑色;
溢出:隐藏;
边界:1px#FFF;
填充:2px;
左侧填充:4px;
文本对齐:左对齐;
}
#马奎尔集装箱img{
边框宽度:2倍;
边框样式:实心;
}
var delayb4scroll=2000//指定字幕开始在页面上滚动之前的初始延迟(2000=2秒)
var marqueespeed=1//指定选框滚动速度(越大,速度越快1-10)
var pauseit=1//mousever上的暂停选框(0=no.1=yes)?
var copyspeed=marqueespeed//marqueespeed=1
var pausespeed=(pauseit==0)?copyspeed:0//如果pauseit=0,则pausespeed=copyspeed;如果不是,则pausespeed=0
var actualwidth=''//actualwidth未定义
var cross_品牌;
交叉变量2;
var Start=1
函数scrollmarquee(){

if(parseInt(cross_marquee.style.left)下面的代码现在可以工作了!我在initialize marquee函数中添加了一个if语句和-clearInterval(lefttime);代码现在在页面刷新时是一致的,如果用户选择了一个提交按钮,它也会刷新页面

<html>
<style type="text/css">

#marqueecontainer{
position: relative;
width: 1020px; /*marquee width */
height: 30px; /*marquee height */
background-color:#FFF;
color:black;
overflow: hidden;
border: 1px #FFF;
padding: 2px;
padding-left: 4px;
text-align:left;
}

#marqueecontainer img {
border-width:2px;
border-style:solid;
}

</style>

<script type="text/javascript">

var delayb4scroll=300 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?


var copyspeed=marqueespeed // marqueespeed = 1
var pausespeed=(pauseit==0)? copyspeed: 0 // if pauseit = 0 then pausespeed = copyspeed if not then pausespeed = 0
var actualwidth='' // actualwidth is undefined

var cross_marquee;
var cross_marquee2;
var lefttime;
var lefttime;


var Start = 1;

function scrollmarquee(){
if (parseInt(cross_marquee.style.left)<(actualwidth*(-1)+4))
    cross_marquee.style.left=(parseInt(cross_marquee2.style.left)+actualwidth+4)+"px"
else
  cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
if (parseInt(cross_marquee2.style.left)<(actualwidth*(-1)+4))
    cross_marquee2.style.left=(parseInt(cross_marquee.style.left)+actualwidth+4)+"px"
else    
    cross_marquee2.style.left=parseInt(cross_marquee2.style.left)-copyspeed+"px"

}

function initializemarquee(){
  if(Start==1) {
    clearInterval(lefttime);
    cross_marquee=document.getElementById("vmarquee")
    cross_marquee2=document.getElementById("vmarquee2")
    cross_marquee.style.left=0
//marqueewidth=document.getElementById("marqueecontainer").offsetWidth 
    actualwidth=cross_marquee.firstChild.offsetWidth    
    cross_marquee2.style.left=actualwidth+4+'px'
    cross_marquee2.innerHTML=cross_marquee.innerHTML
    Start=0;
    setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll) 
    }
}

function Scroll() {
    initializemarquee();
 }    

//onload = Scroll(); // in Cognos this goes here -- in regular html goes in body tag (below)


if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee

</script>
<body onLoad="Scroll()">
<div style="overflow:hidden" >
<div id="marqueecontainer" onMouseover="copyspeed=pausespeed;"  onMouseout="copyspeed=marqueespeed;"> <span id="vmarquee" style="position: absolute; width: 98%;"><nobr>
<!--SCROLL CONTENT HERE-->
<table >
<tr>
<td nowrap>
test test test test test test 
</td>
</tr>
</table>
</nobr> </span><span id="vmarquee2" style="position: absolute; width: 98%;"></span></div> </div>
</body>
</html>

#马奎尔集装箱{
位置:相对位置;
宽度:1020px;/*选框宽度*/
高度:30px;/*选框高度*/
背景色:#FFF;
颜色:黑色;
溢出:隐藏;
边界:1px#FFF;
填充:2px;
左侧填充:4px;
文本对齐:左对齐;
}
#马奎尔集装箱img{
边框宽度:2倍;
边框样式:实心;
}
var delayb4scroll=300//指定字幕开始在页面上滚动之前的初始延迟(2000=2秒)
var marqueespeed=1//指定选框滚动速度(越大,速度越快1-10)
var pauseit=1//mousever上的暂停选框(0=no.1=yes)?
var copyspeed=marqueespeed//marqueespeed=1
var pausespeed=(pauseit==0)?copyspeed:0//如果pauseit=0,则pausespeed=copyspeed如果不是,则pausespeed=0
var actualwidth=''//actualwidth未定义
var cross_marquee;
var cross_marquee2;
时间;
时间;
var Start=1;
函数scrollmarquee(){

if(parseInt(cross_marquee.style.left)如果您发布代码,可能有人可以帮助您修复代码,但关于在何处查找代码或库的建议是离题的。除了离题之外,我不确定我是否理解您试图解决的问题。感谢您添加代码。问题现在重新打开。因此,在测试后-如果我在initializemar上发出警报,我会看到这一点quee,在页面刷新-initializemarquee再次运行…这会导致速度变化吗?