3

I'm developing news website in asp.net, and I want to make news bar that move news from right to left , I have did it with Marquee tag but the problem is I want it to repeat its content without any jabs, as it is finished and then start from the beginning, I want it to be repeated continuously

any help please

Thanks in Advance

Amira Elsayed Ismail
  • 9,216
  • 30
  • 92
  • 175

5 Answers5

4

If you must have marquee functionality then try using a jQuery plugin such as simplyScroll v1 which supports continuous scrolling (ie. it seamlessly wraps around). Note, however, that marquees are considered bad for usability and accessibility in the same way the old <blink> tag was - see http://en.wikipedia.org/wiki/Marquee_element#Usability_problems

Dan Diplo
  • 25,076
  • 4
  • 67
  • 89
2


I believe this will help you:

 <script type="text/javascript" language="javascript">
    function objWidth(obj) {
        if (obj.offsetWidth) return obj.offsetWidth;
        if (obj.clip) return obj.clip.width;
        return 0;
    }
    var mqr = [];

    function mq(id) {
        this.mqo = document.getElementById(id);
        var wid = objWidth(this.mqo.getElementsByTagName('span')[0]) + 5;
        var fulwid = objWidth(this.mqo);
        var txt = this.mqo.getElementsByTagName('span')[0].innerHTML;
        this.mqo.innerHTML = '';
        var heit = this.mqo.style.height;
        this.mqo.onmouseout = function () {
            mqRotate(mqr);
        };
        this.mqo.onmouseover = function () {
            clearTimeout(mqr[0].TO);
        };
        this.mqo.ary = [];
        var maxw = Math.ceil(fulwid / wid) + 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.left = (wid * i) + 'px';
            this.mqo.ary[i].style.width = wid + 'px';
            this.mqo.ary[i].style.height = heit;
            this.mqo.appendChild(this.mqo.ary[i]);
        }
        mqr.push(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.left = (parseInt(x.left, 10) - 1) + 'px';
            }
            var y = mqr[j].ary[0].style;
            if (parseInt(y.left, 10) + parseInt(y.width, 10) < 0) {
                var z = mqr[j].ary.shift();
                z.style.left = (parseInt(z.style.left) + parseInt(z.style.width) * maxa) + 'px';
                mqr[j].ary.push(z);
            }
        }
        mqr[0].TO = setTimeout('mqRotate(mqr)', 10);
    }
 </script>

 <script type="text/javascript">
    function start() {
        new mq('m1');
        mqRotate(mqr);
    }

    window.onload = start;
 </script>

 <div id="m1" class="marquee">
    <span>Example for Continous Text</span>
 </div>
Ian Campbell
  • 2,678
  • 10
  • 56
  • 104
Prince Antony G
  • 932
  • 4
  • 18
  • 39
0

I believe this site has implementation that meets your requirement http://www.givainc.com/labs/marquee_example.htm

SO link

Community
  • 1
  • 1
Sandeep G B
  • 3,957
  • 4
  • 26
  • 43
  • actually no, This example my help you understand what I want, http://javascript.about.com/library/blcmarquee1.htm , but this is for images and also is not connecting to database it is static – Amira Elsayed Ismail Nov 23 '11 at 08:55
0

If you want a news scroller you can try this plugin for jQuery liScroll, I don't know if you want to refresh the news without page reload?

Link: http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html

Niels
  • 48,601
  • 4
  • 62
  • 81
0
<asp:Literal ID="Literal1" runat="server"></asp:Literal>

Then you can give value for the literal.

protected void Page_Load(object sender, EventArgs e)
{
    string str = "get data from database";
    string text = "<MARQUEE>" + str + "</MARQUEE>";
    Literal1.Text = text;
}

I think this website is useful. http://www.dynamicdrive.com/dynamicindex2/

http://www.htmlcodetutorial.com/_MARQUEE.html

Prince Antony G
  • 932
  • 4
  • 18
  • 39