新闻滚动java脚本 [英] news scroller java script

查看:63
本文介绍了新闻滚动java脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个新闻滚动条,当我运行页面时,它无法正常运行,

然后它不滚动,保持不变但是当我将鼠标悬停在婴儿车上时,它'我开始滚动,

我想要的东西。我运行页面时必须运行新闻滚动条,这是代码请修改这个。根据我的说法。









i have added a news scroller , which is not working properly , when i run the page ,
then it''s not scrolling , remain constant but when i mouse over the stroller, it''s began to scroll ,
what i want that . news scroller must be running when i run the page, this is the code please modify this. according to me.




<script type="text/javascript">

        function start() {
            new mq('m1');
            new mq('m2');
            mqRotate(mqr); // must come last
        }
        window.onload = start;


        // Continuous text Vertical Scroller with stop/start button
        // copyright 14th August 2010 by Stephen Chapman
        // http://javascript.about.com
        // permission to use this Javascript on your web page is granted
        // provided that all of the code below in this script (including these
        // comments) is used without any alteration
        function startstopchange(m, txt) { for (var j = m.length - 1; j > -1; j--) document.getElementById('ss' + m[j].id).value = txt; }
        function startstop(m, n) {
            var ss = document.createElement('form'); var sd = document.createElement('div'); ss.appendChild(sd); var sb = document.createElement('input');
            sb.type = 'button'; sd.appendChild(sb); sb.id = 'ss' + n.id; sb.value = 'STOP'; sb.onclick = function () { if (this.value == 'STOP') { clearTimeout(m[0].TO); startstopchange(m, 'START'); } else { mqRotate(m); startstopchange(m, 'STOP'); } }; n.parentNode.insertBefore(ss, n);
        }
        function objHeight(obj) { if (obj.offsetHeight) return obj.offsetHeight; if (obj.clip) return obj.clip.height; return 0; } var mqr = []; function mq(id) { this.mqo = document.getElementById(id); var ht = objHeight(this.mqo.getElementsByTagName('div')[0]) + 5; var fulht = objHeight(this.mqo); var txt = this.mqo.getElementsByTagName('div')[0].innerHTML; this.mqo.innerHTML = ''; var wid = this.mqo.style.width; this.mqo.onmouseout = function () { mqRotate(mqr); startstopchange(mqr, 'STOP'); }; this.mqo.onmouseover = function () { clearTimeout(mqr[0].TO); startstopchange(mqr, 'START'); }; this.mqo.ary = []; var maxw = Math.ceil(fulht / ht) + 1; for (var i = 0; i < maxw; i++) { this.mqo.ary[i] = document.createElement('div'); this.mqo.ary[i].innerHTML = txt; this.mqo.ary[i].style.position = 'absolute'; this.mqo.ary[i].style.top = (ht * i) + 'px'; this.mqo.ary[i].style.height = ht + 'px'; this.mqo.ary[i].style.width = wid; this.mqo.appendChild(this.mqo.ary[i]); } mqr.push(this.mqo); startstop(mqr, this.mqo); } function mqRotate(mqr) { if (!mqr) return; for (var j = mqr.length - 1; j > -1; j--) { maxa = mqr[j].ary.length; for (var i = 0; i < maxa; i++) { var x = mqr[j].ary[i].style; x.top = (parseInt(x.top, 10) - 1) + 'px'; } var y = mqr[j].ary[0].style; if (parseInt(y.top, 10) + parseInt(y.height, 10) < 0) { var z = mqr[j].ary.shift(); z.style.top = (parseInt(z.style.top) + parseInt(z.style.height) * maxa) + 'px'; mqr[j].ary.push(z); } } mqr[0].TO = setTimeout('mqRotate(mqr)', 10); }

    </script>



s








s



<style type="text/css">

.marquee {position:relative;
     overflow:hidden;
     width:100px;
     height:200px;
     border:solid black 1px;
     }

    </style>













<div id="m1" class="marquee">
         <div>
         my name is ....
         </div>
         </div>

推荐答案

this.mqo.onmouseout = function () { mqRotate(mqr); startstopchange(mqr, 'STOP'); }; this.mqo.onmouseover = function () { clearTimeout(mqr[0].TO); startstopchange(mqr, 'START'); }



这两种方法负责启动/停止鼠标悬停/滚出。因此,在加载页面后调用此启动方法将起作用。


this two methods is responsible to start/stop the scroll on mouse over/out. So call this start method on after loading the page will work.


这篇关于新闻滚动java脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆