117
rated 0 times
[
120]
[
3]
/ answers: 1 / hits: 199513
/ 12 Years ago, fri, may 11, 2012, 12:00:00
I'm trying to find a very simple and smooth, lightweight javascript or jquery marquee. I already tried silk marquee or something, but it wouldn't work with the application I was using. So the simpler and shorter, the better - and easier to debug. Does anybody know of a easy to implement javascript replacement for the marquee?
Code
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml xml:lang=en lang=en>
<head>
<script type=text/javascript>
var tWidth='300px'; // width (in pixels)
var tHeight='25px'; // height (in pixels)
var tcolour='#ffffcc'; // background colour:
var moStop=true; // pause on mouseover (true or false)
var fontfamily = 'arial,sans-serif'; // font for content
var tSpeed=3; // scroll speed (1 = slow, 5 = fast)
// enter your ticker content here (use / and ' in place of / and ' respectively)
var content='Are you looking for loads of useful information <a href=http://javascript.about.com/>About Javascript</a>? Well now you've found it.';
var cps=-tSpeed; var aw, mq; var fsz = parseInt(tHeight) - 4; function startticker(){if (document.getElementById) {var tick = '<div style=position:relative;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+''; if (moStop) tick += ' onmouseover=cps=0 onmouseout=cps=-tSpeed'; tick +='><div id=mq style=position:absolute;right:0px;top:0px;font-family:'+fontfamily+';font-size:'+fsz+'px;white-space:nowrap;></div></div>'; document.getElementById('ticker').innerHTML = tick; mq = document.getElementById(mq); mq.style.right=(10+parseInt(tWidth))+px; mq.innerHTML='<span id=tx>'+content+'</span>'; aw = document.getElementById(tx).offsetWidth; lefttime=setInterval(scrollticker(),50);}} function scrollticker(){mq.style.right = (parseInt(mq.style.right)>(-10 - aw)) ?
mq.style.right = parseInt(mq.style.right)+cps+px: parseInt(tWidth)+10+px;} window.onload=startticker;
</script>
</head>
<body>
<div id=ticker>
this is a simple scrolling text!
</div>
</body>
</html>
More From » jquery