PDA

View Full Version : Need Help to Modify "Typing Scroller" script!



Manhattan
05-19-2010, 12:23 PM
1) Script Title: Typing Scroller

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/typescroll.htm

3) Describe problem:

Hi there, I just want to know how I can define a particular color for each line in this script?
I tried this but unfortunately the font tag does not parse correctly.

line[1]="<font style='color: red'> This is an awsome script</font>"

Beverleyh
05-19-2010, 01:09 PM
Try span tags instead - you might have to escaped the apostrophes too:

line[1]="<span style=\'color: red\'> This is an awsome script</span>"

Manhattan
05-19-2010, 01:31 PM
Thanks, but it didn't help, tags are typed as well as the phrase!!

ddadmin
05-19-2010, 09:11 PM
The scroller is actually shown inside a FORM INPUT element, so you can't simply change the font color by surrounding each text with a colored SPAN element, for example. Are you asking how to change the color individually for each message, or just the color of the scroller in general? The later is easy to do, just edit the line below:


document.write(' style="background-color: '+document.bgColor+'; color: '+document.body.text+'; font-family: verdana; font-size: '+ts_fontsize+'; font-weight:bold; border: medium none" onfocus="blur()">')

Replace the code in red with the desired color name, surrounded in quotes, such as 'blue'.

Manhattan
05-20-2010, 06:02 AM
Thanks, yeah, I wanna change the color individually for each message.

ddadmin
05-20-2010, 08:18 PM
Ok, try the below modified script:


<script language="JavaScript1.2">
<!--

/*
Typing Scroller
Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
With modifications by Dynamicdrive.com
For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
*/

//Secify scroller contents
var line=new Array()
line[1]="This is an awsome script"
line[2]="It brings up the text you want..."
line[3]="One letter at a time"
line[4]="You can add and subtract lines as you like."
line[5]="It\'s very cool and easy to use"

//Specify font size for scoller
var ts_fontsize="16px"

var scrollercolors=[
"red",
"blue",
"green",
"black",
"brown"
]

//--Don't edit below this line

var longestmessage=1
for (i=2;i<line.length;i++){
if (line[i].length>line[longestmessage].length)
longestmessage=i
}

//Auto set scroller width
var tscroller_width=line[longestmessage].length

lines=line.length-1 //--Number of lines

//if IE 4+ or NS6
if (document.all||document.getElementById){
document.write('<form name="bannerform">')
document.write('<input type="text" name="banner" size="'+tscroller_width+'"')
document.write(' style="background-color: '+document.bgColor+'; color: '+document.body.text+'; font-family: verdana; font-size: '+ts_fontsize+'; font-weight:bold; border: medium none" onfocus="blur()">')
document.write('</form>')
}

temp=""
nextchar=-1;
nextline=1;
cursor="\\"
function animate(){
if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines){
nextline++;
nextchar=-1;
document.bannerform.banner.value=temp;
temp="";
setTimeout("nextstep()",1000)}
else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){
nextline=1;
nextchar=-1;
document.bannerform.banner.value=temp;
temp="";
setTimeout("nextstep()",1000)}
else{
nextstep()}}

function nextstep(){
if (cursor=="\\"){
cursor="|"}
else if (cursor=="|"){
cursor="/"}
else if (cursor=="/"){
cursor="-"}
else if (cursor=="-"){
cursor="\\"}
document.bannerform.banner.style.color=scrollercolors[nextline-1]

nextchar++;
temp+=line[nextline].charAt(nextchar);
document.bannerform.banner.value=temp+cursor
setTimeout("animate()",25)}

//if IE 4+ or NS6
if (document.all||document.getElementById)
window.onload=animate
// -->
</script>


Edit the array in red with the desired colors. The number of colors defined should equal the number of messages you have.

Manhattan
05-21-2010, 08:14 AM
Thank you very much ddadmin, it works like a charm!