Link to home
Start Free TrialLog in
Avatar of MichaelVB
MichaelVB

asked on

Javascript font color

Hello All,

I am using a javascript function I found on the internet to display a progress bar on the screen. My problem is that right now the progress bar "text", the text that moves across the screen to simulate that something is happening is black. I would like to make it another color but can't seem to find the proper syntax for doing this?

Any help? This is the code
var _progressBar = new String("");
_progressBar.fontcolor('red');   // THIS DOES NOT WORK?
var _progressEnd = 10;
var _progressAt = 0;
var _progressWidth = 150;      // Display width of progress bar

Thanks for the help.
Mike
Avatar of VincentPuglia
VincentPuglia

Hi,

document.write('<div id="bar">' + _progressBar + '</div>')
document.getElementById('bar').style.color = 'red';  

Vinny
Are you sure this is Javascript ?   for one thing variable-names starting with an '_' character should not be used (they are reserved for predefined values)

I am afraid I would need to see the entire script to make sense of this. could you give a link to the place where you found it?
I can not see  your code but I would image you are using a span,div,table or cell  with some id or a name for the bar.  I think you need this you want this

var _progressBarColor='red'  
var _progressEnd = 10;

if  obj is the name or id and where you have something like this for a span or div  

document.getElementById('obj').style.color = _progressBarColor
or
document.getElementByIName('obj').style.color = '_progressBarColor

 for a table cell replace 'color' with 'background'

ASKER CERTIFIED SOLUTION
Avatar of GwynforWeb
GwynforWeb
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MichaelVB

ASKER

this is where I found the code

http://javascript.internet.com/messages/progress-dialog.html

thanks,
Mike
Avatar of devic
hey MichaelVB ,

maybe do you want prototype?
here is example:
===================================
<script>
function runit()
{

var progressBar = new String("Any help? This is the code");
String.prototype.color = "red";
String.prototype.colored = textColor;
progressBar = progressBar.colored();

document.write(progressBar)
}

function textColor()
{
   return "<FONT color='" + this.color  + "'>" + this + "</FONT>";
}
</script>
<button onclick=runit()>runit</button>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, That script is horribly Old. written for IE4 and Netscape4. It might work in newer versions of IE, but not in newer netscape or any browser using the DOM model.

I would suggest you scrap it and replace it with code based on GwynforWebs code. evt get him to complete it. ( but no variablenames starting with '_' please :)