Home > front end >  Could you tell me how to modify this js
Could you tell me how to modify this js

Time:09-24




<meta charset="utf-8" & gt;
<meta name="viewport" content="width=device - width, initial - scale=1.0" & gt;
<meta HTTP - equiv="X - UA - Compatible" content="ie=edge" & gt;
Document
<style>
* {
margin: 0;
padding: 0;
}

Div {
width: 100px;
Height: 63 px;
/* must */
overflow: hidden;
/* must */
Margin: 50 px auto;
Border: 1 px solid red;
text-align: center;
}

Ul {
list-style: none;
}
</style>


<body>


  • The first article & lt;/li>

  • Article 2 the term "& lt;/li>

  • Article 3 & lt;/li>

  • Article 4 & lt;/li>

  • Article 5 & lt;/li>

  • Article 6 & lt;/li>




<script>
Window. The onl oad=roll (50);

The function roll (t) {
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
Ul2. InnerHTML=ul1. InnerHTML;
Ulbox. ScrollTop=0;//without scrolling to 0
Var timer=setInterval (rollStart, t);//set the timer, parameter t in this interval of time (in milliseconds), the parameter t is smaller, the faster the scrolling
//pause when the mouse moves into div scroll
Ulbox. onm ouseover=function () {
clearInterval(timer);
}
//mouse after removed div continue rolling
Ulbox. onm ouseout=function () {
The timer=setInterval (rollStart, t);
}
}

//start rolling function
The function rollStart () {
//the above statement of the DOM object for local objects need again
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
//normal rolling continuously to the scrollTop value + 1, when the height is greater than the rolling list content height recovery of 0
If (ulbox scrollTop & gt;=ul1. ScrollHeight) {
Ulbox. ScrollTop=0;
} else {
Ulbox. ScrollTop++;
}
}
</script>




Is a scroll up to the code above, but after page zoom percentage is less than eighty percent, will not be rolling, page after a period of time, the mouse to scroll stop events also can appear abnormal, could you tell me how to modify the compatible with perfect better

CodePudding user response:

Replace the js code
//is reduced to a certain degree of fixed page of reason is ulbox. Every increase 1 px scrollTop++ through narrowing the neglected to 0 
Window. The onl oad=function () {
Var h=0;//height, since, avoid being resized ignore
Var isStop=false;//stop
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
Ul2. InnerHTML=ul1. InnerHTML;
Ulbox. onm ouseover=function () {
IsStop=true
}
Ulbox. onm ouseout=function () {
IsStop=false
}
SetInterval ()=& gt; {
if(! IsStop) {
H=h & gt; 1=ul1 scrollHeight? 0: h + 1
Ulbox. ScrollTop=h
}
}, 50)
};

CodePudding user response:

Marquee

Scrolling is better

CodePudding user response:

reference 1st floor SCSCMS sunlight response:

replace js code
//is reduced to a certain degree of fixed page of reason is ulbox. Every increase 1 px scrollTop++ through narrowing the neglected to 0 
Window. The onl oad=function () {
Var h=0;//height, since, avoid being resized ignore
Var isStop=false;//stop
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
Ul2. InnerHTML=ul1. InnerHTML;
Ulbox. onm ouseover=function () {
IsStop=true
}
Ulbox. onm ouseout=function () {
IsStop=false
}
SetInterval ()=& gt; {
if(! IsStop) {
H=h & gt; 1=ul1 scrollHeight? 0: h + 1
Ulbox. ScrollTop=h
}
}, 50)
};


reference 1st floor SCSCMS sunlight response:

replace js code
//is reduced to a certain degree of fixed page of reason is ulbox. Every increase 1 px scrollTop++ through narrowing the neglected to 0 
Window. The onl oad=function () {
Var h=0;//height, since, avoid being resized ignore
Var isStop=false;//stop
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
Ul2. InnerHTML=ul1. InnerHTML;
Ulbox. onm ouseover=function () {
IsStop=true
}
Ulbox. onm ouseout=function () {
IsStop=false
}
SetInterval ()=& gt; {
if(! IsStop) {
H=h & gt; 1=ul1 scrollHeight? 0: h + 1
Ulbox. ScrollTop=h
}
}, 50)
};


reference 1st floor SCSCMS sunlight response:

replace js code
//is reduced to a certain degree of fixed page of reason is ulbox. Every increase 1 px scrollTop++ through narrowing the neglected to 0 
Window. The onl oad=function () {
Var h=0;//height, since, avoid being resized ignore
Var isStop=false;//stop
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
Ul2. InnerHTML=ul1. InnerHTML;
Ulbox. onm ouseover=function () {
IsStop=true
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related