PDA

View Full Version : Alternative to <marquee>?



Trigs
19-06-2010, 03:01 PM
Are there any alternatives to <marquee>? I don't want to use it since it's deprecated. Is there some way to do this in javascript, etc.?

Special
19-06-2010, 03:07 PM
<script type="text/javascript">
function beginrefresh(){
var marquee=document.getElementById("marquee_text");//set the id of the target object
if(marquee.scrollLeft>=marquee.scrollWidth-parseInt(marquee.style.width))marquee.scrollLeft=0 ;
marquee.scrollLeft+=1;
setTimeout("beginrefresh()",10);//set the delay (ms), bigger delay, slower movement
}
</script>

from google dunno if that helps

Trigs
19-06-2010, 03:44 PM
I found this: http://remysharp.com/2008/09/10/the-silky-smooth-marquee/

I'm not good with JS so I don't really know how to implement it.

In the the <head>, I put


<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="marquee.js"></script>
<script type="text/javascript">
$(function () {
$('div.breadcrumb marquee').marquee('pointer').mouseover(function () {
$(this).trigger('stop');
}).mouseout(function () {
$(this).trigger('start');
}).mousemove(function (event) {
if ($(this).data('drag') == true) {
this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
}
}).mousedown(function (event) {
$(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
}).mouseup(function () {
$(this).data('drag', false);
});
});
</script>

And in the <body> where I want my marquee to go I put


<marquee behavior="scroll" direction="left" scrollamount="2" width="100%">
<b>Latest News:</b> <a href="#">Welcome!</a> (03/01/10) | <b>Today's Birthdays:</b> <a href="#">Dylan</a> (34), <a href="#">John</a> (16), <a href="#">Bob</a> (70)
</marquee>

I've never used jquery before so I'm not to sure how to implement it.

Cherpi
23-06-2010, 07:22 AM
What's wrong with Marquee, you can set it to go left or right, up or down, it's fine?

Apolva
23-06-2010, 09:32 AM
What's wrong with Marquee, you can set it to go left or right, up or down, it's fine?

I don't want to use it since it's deprecated

Means it's "looked down upon" my designers and might not be supported in future.

Trigs
23-06-2010, 10:27 PM
It's not xHTML valid plus it's a ***** to click links on a marquee (with JS I can make it stop on mouseover). Also, most browsers don't render it properly (choppy scrolling, etc.)

Want to hide these adverts? Register an account for free!