| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
Scrolling Button
<!--
this code was written by Mickel Version 1.0 -- 21 August 2001 --> <HTML> <HEAD> <TITLE>Scrolling Button Test</TITLE> <SCRIPT> // Setting some global variables here var ScrollPos = 0; // Initial Index of position in MyScrollText var NormalText; // Text of the button before mouseover var MyObject;// Object to be manipulated var MyScrollText; // Text to be scrolled on object var MyInterval; // ID for Interval var Spaces = ""; // Spaces for padding // Usage SetScroll(true|false,this,[Text // to be Scrolled]) function SetScroll(Activate,Object,ScrollText) { if (Activate == true) // Check to see if scroll needs to be started when mouse is over object { NormalText = Object.value; // NormalText is actual Object var Spaces = ""; for (i=0;i < NormalText.length; i++) Spaces += " "; // Padding for scroll text is a Space MyObject = Object; // MyObject is this object MyScrollText = Spaces + ScrollText + Spaces; // Adding spaces on each side for scrolling effect MyInterval = window.setInterval("ScrollText();", 100); // Set interval for 100 mseconds (Change this number for fast or slower scrolls) } else { window.clearInterval(MyInterval); // Mouse has left the object, interval in cleared (cancelled) ScrollPos = 0; // Index for position in MyScrollText has been set back to initial value if (NormalText != null) // If the NormalText has a value Object.value = NormalText; // Set the button back to its original value } } function ScrollText() { MyObject.value = MyScrollText.substr(ScrollPos,NormalText.length) // Object text becomes substring of MyScrollText ScrollPos ++; // ScrollPos is increased by 1 if (ScrollPos > MyScrollText.length) // If the ScrollPos if more than the length of MyScrollText ScrollPos = 0; // then the Index position will be set back to 0 (beginning) } </SCRIPT> </HEAD> <BODY> <! You can use any button with any name> <! Change to width of the button for accomodate your text> <INPUT type="button" style="width:100" value="Test Button" onmouseover="SetScroll(true,this,'Click here to do Something!');" onmouseout="SetScroll(false,this)"> <!Also works with an Input Box or similar objects that use the value method> </BODY> </HTML> |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Scrolling Button |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|