NinethSense oWnZ mE!: Praveen’s drawing book

Choose a Topic:

Fri
24
Nov '06

Contineous Javascript Marquee

This script will let the text scroll contineously. This means, the second round scroll will start just after first round. This will overcome the in-between delay of HTML MARQUEE tag. However, this script is not free from limitations. But works on both IE & Firefox.


 
<html>
	<head>
		<script language=“javascript”>
		var text = “There is a long sentence With some more text However as soon as this message plays There’s a really long break Before the text starts Over.”; // User Text
		var i = 0;
		var n = 50;	// Number of Charaters to display
		var speed = 50; // Scroll speed in milliseconds
		text = text + text.substring(0,n)
		function marqueeText() {
			document.getElementById(“divText”).innerHTML = text.substring(i,i+n);
			i++;
			if (i > text.length - n ) i = 0;
			setTimeout(‘marqueeText()’, speed);
		}
		</script>
	</head>
	<body>
		<div id=“divText” style=“border:solid 1px gray;background-color:#CCCCCC “ align=“center”></div>
	</body>
</html>
 
<script language=“javascript”>
	marqueeText();
</script>
The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website