...

View Full Version : How to Change the color and length of scolling script



javanovice2
12-18-2010, 09:47 AM
Hi all,

I have a free script I have downloaded and I can't figure out how to edit it so that I can change the color of the text to whatever I want it to be and also so that the length of the scrolling text (I am not sure if scrolling is the right term) can be changed.

For some reason the text does not go all the way to the end of the page on the right it stops quite a way before.

Here is the code:



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

/*
Typing Scroller
For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
*/

//Secify scroller contents
var line=new Array()
line[1]="Testing testing one to three and you can test some more."
line[2]="Always testing always testing"
line[3]="Trying to test some more and some more again"
line[4]="second to last bit of testing."
line[5]="Testing text that is just testing one more time"

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

//--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: arial; 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=""}


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>



I have been trying to figure this out for about 2 hours but since I am a 100% novice with javascript I have not got very far.

Any help would be gratefully recieved. :)

Sciliano
12-18-2010, 11:59 AM
javanovice2:

Any "script" which uses document.write is long obsolete.

Try this, instead:

http://www.dynamicdrive.com/forums/showthread.php?t=49532

Philip M
12-18-2010, 12:03 PM
As sciliano says, this is long-obsolete code.

<script language=javascript> is long deprecated and obsolete. Use <script type = "text/javascript"> instead.
The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that (as here) you are looking at ancient and perhaps unreliable code.

javanovice2
12-18-2010, 12:54 PM
javanovice2:

Any "script" which uses document.write is long obsolete.

Try this, instead:

http://www.dynamicdrive.com/forums/showthread.php?t=49532


As sciliano says, this is long-obsolete code.

<script language=javascript> is long deprecated and obsolete. Use <script type = "text/javascript"> instead.
The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that (as here) you are looking at ancient and perhaps unreliable code.

Thanks to the both of you.

I have learned something today. I am not longer a novice I am now one up from a novice.

I will take a look at the link suggested.

javanovice2
12-29-2010, 12:45 AM
javanovice2:

Any "script" which uses document.write is long obsolete.

Try this, instead:

http://www.dynamicdrive.com/forums/showthread.php?t=49532

I tried that script and I couldn't get the text to show up on the crawler for some reason so I actually bought I bunch of scripts from the site hoping to get one that works and I still can't get the script to show up.

I have a feeling it might be because the code is out of date or not compatible with my doc type, and needs to be tweaked a bit.

It also shows different results in IE than it does in Firefox.

Help...

As my username suggests I am a total novice and I am trying to learn this stuff but for now I just need a working script or two to get me going.

Any advice would be greatfully recieved. :)

javanovice2
12-29-2010, 09:26 AM
I still haven't found the answer to this one. I have emailed the developer and am awaiting a reply.

I will be doing some more research myself, but I suspect it is a very simple fix for anyone that is an expert.

Sciliano
12-29-2010, 12:22 PM
I inserted the crawler in to your page and fixed several errors in your markup. You need to validate both the markup and css, here:

http://validator.w3.org/

http://jigsaw.w3.org/css-validator/

You shouldn't use tables for page layout. Use CSS.

Your document is an example to others of everything to avoid. It uses the worst of the worst practices. I'd scrap it and start anew.

Hashim1
12-29-2010, 03:09 PM
javanovice2:

Any "script" which uses document.write is long obsolete.

Try this, instead:

http://www.dynamicdrive.com/forums/showthread.php?t=49532

By obsolete, I assume you mean it's no longer in use? So, if I used document.write in a script, it wouldn't work at all?

javanovice2
12-29-2010, 03:37 PM
Your document is an example to others of everything to avoid. It uses the worst of the worst practices. I'd scrap it and start anew.

Strong words. I feel like a naughty school child.:(

I really appreciate your frankness and the fact that you say it like it is.

The truth is I am a novice trying to do things on a shoe string budget and I tried using css but I just couldn't get things to look right. However, I will look at it again and try to scrape the tables.

Saying it's an an example of EVERYTHING to avoid, I think was a bit over the top, but point taken. I much rather you talk to me straight as you have and help, as you have, rather than not get involved.

Thanks, I really appreciate it and I will implement what you have attached.:)

I can't thank you enough for helping me out. I have been at this for hours and it has been driving me crazy.

Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum