I'm developing news website in asp, 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
I'm developing news website in asp, 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
Share Improve this question asked Nov 23, 2011 at 8:44 Amira Elsayed IsmailAmira Elsayed Ismail 9,41432 gold badges98 silver badges185 bronze badges5 Answers
Reset to default 4If 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/wiki/Marquee_element#Usability_problems
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>
I believe this site has implementation that meets your requirement http://www.givainc./labs/marquee_example.htm
SO link
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/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
<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./dynamicindex2/
http://www.htmlcodetutorial./_MARQUEE.html