Home > front end >  Realize the image random rolling, error code, didn't find out the problem
Realize the image random rolling, error code, didn't find out the problem

Time:09-21

Browser card dead, what the cause of the purpose is to make random rolling images, please help??? The great spirit




<meta charset="utf-8">
No title documents & lt;/title> <br/><style> <br/># box {width: 300 px; height: 400px; margin: 0 auto; border: 1px solid #000; Background: # FBE9EF; }<br/>Ul {padding: 0; margin: 0; float: left; }<br/>Li {list - style: none; Width: 125 px; height: 90px; Margin: 0 px 10 px 5 px 10 px; border: 1px solid #000; position: relative; Overflow: hidden; }<br/>Img {width: 125 px; height: 90px; vertical-align: top; position: absolute; }<br/>The img1 {top: 0; left: 0; }<br/>. Img2 {top: 90 px; left: 0; }<br/></style> <br/><script> <br/>Window. The onl oad=function () {<br/>Var aImg=document. GetElementsByTagName (" img "); <br/>Var aImg1=document. GetElementsByClassName (' img1 '); <br/>Var aImg2=document. GetElementsByClassName (" img2 "); <br/>Var aLi=document. GetElementsByTagName (" li "); <br/>var arr=[]; <br/>Var arrImg=[' Img/1. GIF ', 'Img/2. GIF', 'Img/3. GIF', 'Img/4. GIF', 'Img/5. GIF', 'Img/6. GIF', 'Img/7. GIF', 'Img/8. GIF', 'Img/9. GIF', 'Img/10. GIF', 'Img/11. GIF', 'Img/12. GIF', 'Img/13. GIF', 'Img/14. GIF', 'Img/15. GIF', 'Img/16. GIF']. <br/>var timer=null; <br/><br/>for(var i=0; I<AImg. Length; I++) {<br/>AImg [I] src=https://bbs.csdn.net/topics/arrImg [I]; <br/>AImg [I] index=true; <br/>}; <br/><br/>The timer=setInterval (function () {<br/>The Random ();//random number 1-8 random repeats <br/>for(var i=0; I<Arr. Length; I++) {<br/>Var arr=j [I]; <br/>If (aImg1 [j]. Journal of index) {<br/>DoMove (aImg1 [j], 'top', 10, 90, the function () {<br/>AImg1 [j]. Journal of index=false; <br/>}); <br/>DoMove (aImg2 [j], 'top', 10, 0). <br/>} else {<br/>DoMove (aImg1 [j], 'top', 10, 0, the function () {<br/>AImg1 [j]. Journal of index=true; <br/>}); <br/>DoMove (aImg2 [j], 'top', 10, living); <br/>}<br/>}<br/><br/>}, 2000); <br/><br/>Function the Random () {//Random number 1-8 Random repeats <br/><br/>Var Num=math.h ceil (Math. The random () * aLi in length). <br/><br/>While (arr. Length<Num)={<br/>Var isRandom=Math. Round (Math. The random () * (aLi. Length - 1)); <br/>If (arr. Length==0) {<br/>Arr. Push (isRandom); <br/>} else {<br/>If (arr. Join (', '). IndexOf (isRandom)==1) {<br/>Arr. Push (isRandom); <br/>}<br/>}<br/>}<br/><br/>}; <br/><br/><br/>The function doMove (obj, attr, dir, target, endFn) {<br/><br/>Dir=parseInt (getStyle (obj, attr)) & lt; The target? Dir: - dir;//dir=return value <br/><br/>clearInterval(obj.timer); <br/><br/>Obj. Timer=setInterval (function () {<br/><br/>Var speed=parseInt (getStyle (obj, attr)) + dir. <br/><br/>If (speed<Target & amp; & Dir<0 | | speed> Target & amp; & Dir> 0 {<br/>Speed=target; <br/>}<br/><br/>Obj. Style [attr]=speed + 'px'; <br/><br/>If (speed==target) {<br/>clearInterval(obj.timer); <br/>//if (endFn) {endFn (); }; <br/>EndFn & amp; & EndFn ();//there is executed <br/>}<br/><br/>40)}, <br/>}; <br/><br/>The function getStyle (obj, attr) {<br/>return obj.currentStyle? Obj. CurrentStyle [attr] : getComputedStyle (obj) [attr]; <br/>}; <br/><br/>}<br/></script> <br/></head> <br/><br/><body> <br/><Div id="box" & gt; <br/><Ul> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/></ul> <br/><Ul> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/><Li> <Img SRC="" Alt=" "& gt; <Img SRC="" Alt=" "& gt; </li> <br/></ul> <br/></div> <br/></body> <br/></html> <br/><p class="article - content rp"> CodePudding user response: </p>You change while the if the commissioning and debugging, while not easy to dead circulation result in a browser<p class="article - content rp"> CodePudding user response: </p><fieldset> <legend> 1/f, reference code for the family's reply: <legend> <blockquote> you change while the if the commissioning and debugging, while not easy to dead circulation result in a browser jammed </blockquote> <fieldset> <br/>Okay, I try, thank you </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/18992.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/18992.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/18991.html'>Do front-end project, switch frame or with the element, the component library such as the ant form c</a></div> <div class="detail-arr-right">Next:<a href='/frontend/18993.html'>Elementui navigation bar folding problem</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=JavaScript' target='_blank'>JavaScript</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>