Solved

Javascript font color

Posted on 2003-11-15
8
1,815 Views
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.
Mike
0
Comment
Question by:MichaelVB
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9754214
Hi,

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

Vinny
0
 
LVL 15

Expert Comment

by:JakobA
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?
0
 
LVL 31

Expert Comment

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

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

0
 
LVL 31

Accepted Solution

by:
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;
etc

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

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

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




0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:MichaelVB
ID: 9754406
this is where I found the code

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

thanks,
Mike
0
 
LVL 25

Expert Comment

by:devic
ID: 9754424
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>
0
 
LVL 25

Assisted Solution

by:devic
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 + "\"");
0
 
LVL 15

Expert Comment

by:JakobA
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 :)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now