Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.




XML
<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



XML
<style type="text/css">

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

    </style>




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

1 solution

HTML
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900