Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 19th, 2006, 05:44 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,266 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 12 h 6 m 3 sec
Reputation Power: 1791
Post JavaScript: Horizontal Text Scroller

The below code would show "horizontal text scroller" i.e. the text
will "scroll" letter by letter.
Code:
<html>
<head>
<title>Horizontal Scroller Example</title>
<script type="text/javascript">
window.onload = WindowLoad;
var _hsSpeed=250; //lower value means faster speed!
var _hsData=new Array();
var _hsCounter=0;
function WindowLoad(event) {
	InitializeHorizontalScroll();
}

function InitializeHorizontalScroll() {
	var arrElements = document.getElementsByTagName("span");
	for (var i=0; i<arrElements.length; i++) {
		var element=arrElements[i];
		if (element.getAttribute("horizontalscroll") == "1") {
			_hsData[_hsCounter] = new Array();
			_hsData[_hsCounter]["element"] = element;
			_hsData[_hsCounter]["text"] = FindInnerText(element);
			_hsData[_hsCounter]["index"] = 0;
			_hsCounter++;
		}
	}
	if (_hsCounter > 0)
		window.setTimeout("HorizontalScrollTimer();", 10);
}
function HorizontalScrollTimer() {
	for (var i=0; i<_hsData.length; i++) {
		var element = _hsData[i]["element"];
		var strText = _hsData[i]["text"];
		var index = parseInt(_hsData[i]["index"]);
		element.innerHTML = strText.substr(0, index+1);
		index++;
		if (index >= strText.length)
			index = 0;
		_hsData[i]["index"] = index;
	}
	window.setTimeout("HorizontalScrollTimer();", _hsSpeed);
}

function FindInnerText(objControl, innerText, nestingLevel)
{
	if ((typeof nestingLevel != "undefined")&&(nestingLevel > 100))
		return innerText;
	
	if (typeof innerText == "undefined")
		innerText = "";
	
	if (!objControl)
		return innerText;
	
	if (typeof nestingLevel == "undefined")
		nestingLevel = 0;
	
	var text=objControl.nodeValue;
	if (!text)
		text = "";
	if (objControl.nodeName.toLowerCase() == "br")
		return "\n";
	
	
	for (var i=0; i<objControl.childNodes.length; i++)
	{
		text += FindInnerText(objControl.childNodes[i], objControl.childNodes[i].nodeValue, nestingLevel+1);
	}
	
	return text;
}
</script>
</head>
<body>
<span horizontalscroll="1">hello world</span>
</body>
</html>

how to use? just follow those instructions:
  1. have the javascript code as-is: you can also put it inside
    seperate js file and include the file using <script src="file.js">
  2. in case you already have onload of your own, just add this
    line to the onload function:
    Code:
    InitializeHorizontalScroll()

    in case you have the onload inside the body tag change this
    to something like:
    Code:
    <body onload="InitializeHorizontalScroll(); whatever_was_before();">
  3. to have scrolling text, put it inside its own span and give the
    span horizontalscroll="1" attribute like in the above sample code.
    note: to change the style of the text you must use CSS and
    change the style of the span itself, no inner style like <b> or
    <font> is allowed. for example to have the text bold:
    Code:
    <span horizontalscroll="1" style="font-weight: bold;">hello world</span>

additional notes:
  • you can have more than one scrolling text in the same page.
    just put each in its own <span horizontalscroll="1"> tag...
  • you can control the speed of the scrolling: change the value
    of _hsSpeed to change the speed in which the letters appear.
    lower number means faster scroll.

any comments or questions are welcome, happy programming!

Last edited by Shadow Wizard : February 19th, 2006 at 05:50 AM.

Reply With Quote
  #2  
Old April 23rd, 2007, 07:29 PM
__CRUZ__ __CRUZ__ is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 __CRUZ__ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 42 sec
Reputation Power: 0
Hello could you please add a mouse over stop and resume for me please?

Last edited by Shadow Wizard : April 24th, 2007 at 04:26 AM.

Reply With Quote
  #3  
Old April 24th, 2007, 04:27 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,266 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 12 h 6 m 3 sec
Reputation Power: 1791
Quote:
Originally Posted by __CRUZ__
Hello could you please add a mouse over stop and resume for me please?
you mean that when the mouse is over the text it won't scroll
and when the mouse leave the text it would scroll again?

Reply With Quote
  #4  
Old April 24th, 2007, 07:59 AM
__CRUZ__ __CRUZ__ is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 __CRUZ__ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 42 sec
Reputation Power: 0
hi thanx for the reply.

I actually need a horozontal scroll upward for a shout box. It needs to loop and scroll up, have a mouse over stop and mouse out resume.Also if it could still have the use of a scroller on the side would be kewl. I thought your post was what i needed but i made a mistake sorry. If you could help me out that would be great tho. thanx again for the reply.

Reply With Quote
  #5  
Old April 25th, 2007, 04:08 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,266 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1Folding Points: 356912 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 12 h 6 m 3 sec
Reputation Power: 1791
"horizontal scroll upward" is like saying "dead man alive" - it's contradiction.
look further in the Code Bank, I have posted vertical scroller somewhere.
this is also much more common thing, you can search google to find
tons of examples with full code.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > JavaScript: Horizontal Text Scroller


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT