Javascript font color

Posted on 2003-11-15
Last Modified: 2013-12-03
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.
Question by:MichaelVB
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
LVL 15

Expert Comment

ID: 9754214

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

LVL 15

Expert Comment

ID: 9754218
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?
LVL 31

Expert Comment

ID: 9754371
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
document.getElementByIName('obj').style.color = '_progressBarColor

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

LVL 31

Accepted Solution

GwynforWeb earned 50 total points
ID: 9754393
typos should read

I can not see your code but I would imagine you are using a span, div, table or table cell  with some id or a name for the bar.  I think you need something like this

var _progressBarColor='red'  
var _progressEnd = 10;

If  obj is the name or id  then use  for a span or div  

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

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


Author Comment

ID: 9754406
this is where I found the code

LVL 25

Expert Comment

ID: 9754424
hey MichaelVB ,

maybe do you want prototype?
here is example:
function runit()

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


function textColor()
   return "<FONT color='" + this.color  + "'>" + this + "</FONT>";
<button onclick=runit()>runit</button>
LVL 25

Assisted Solution

devic earned 200 total points
ID: 9754430
just change this line:
document.write("<input type=text name=\"bar\" size=\"" + _progressWidth/2 + "\"");

to this:
document.write("<input style=color:red type=text name=\"bar\" size=\"" + _progressWidth/2 + "\"");
LVL 15

Expert Comment

ID: 9754433
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 :)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery on click requires double click 6 34
Timer on div 5 26
Making Table Thru ASP Response.write 5 21
javascript form - error when hitting enter 3 28
In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question