473,395 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

text colour

Being new to javascript, I'm stuck on what is obviously a simple thing.
I have a script which finishes with a document.write statement to
print the result to the screen. This is all working OK, but how do I
change the colour of the text and make it bold?

I tried adding style.color = "yellow"; before the write statement,
but the colour was still black.

Any advice would be much appreciated.

TIA

Geoff
Jul 23 '05 #1
3 1343
Ivo
"Geoff" wrote
Being new to javascript, I'm stuck on what is obviously a simple thing.
I have a script which finishes with a document.write statement to
print the result to the screen. This is all working OK, but how do I
change the colour of the text and make it bold?

I tried adding style.color = "yellow"; before the write statement,
but the colour was still black.


You could indeed add "<span style='color:yellow;font-weight:bold;'>" and
"</span>" to whatever you are writing. These statements need to be part of
the string then.
Another possibility is to use the fontcolor() and bold() methods of the
String object. See for example--watch for wrap:
<
http://www.devguru.com/Technologies/..._formatting.ht
ml >

hth
--
ivo

Jul 23 '05 #2
Geoff wrote:
Being new to javascript, I'm stuck on what is obviously a simple thing.
I have a script which finishes with a document.write statement to
print the result to the screen. This is all working OK, but how do I
change the colour of the text and make it bold?

I tried adding style.color = "yellow"; before the write statement,
but the colour was still black.

I would use CSS to style the text's container:

<style type="text/css">
..YourClassName {
font-weight: bold;
color: #FFFF00;
}
</style>

<p class="YourClassName">
<script type="text/javascript">
document.write("Foo");
</script>
</p>

Mick
Jul 23 '05 #3
Geoff wrote:
Being new to javascript, I'm stuck on what is obviously a simple
thing. I have a script which finishes with a document.write
statement to print the result to the screen. This is all working
OK, but how do I change the colour of the text and make it bold?

I tried adding style.color = "yellow"; before the write statement,
but the colour was still black.

Any advice would be much appreciated.

TIA

Geoff


Thanks for your advice guys.

Geoff
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bill Parker | last post by:
Hi Is there a way to generate colour hex strings that are guaranteed to be dark and thus good as random-generated text colours? something like -------------------...
4
by: Bill Davy | last post by:
To make life easier for my users, I'd like to colour my prompt string (as handed to raw_input()) a different colour to that produced by print. I'm using Python 2.4.1 and IDLE 1.1.1 on Windows XP. ...
3
by: kj | last post by:
Is there any way to disable text selection in a web page (or at least render it invisible to the user)? If there is a way to control how selected text and its background are rendered, then the...
4
by: Werner Partner | last post by:
I'm looking for something like that: http://www.sonoptikon.de/praxis-mt/test.php The text should have a certain indent, and from the left border should come a "marker" which goes over the text...
7
by: miked | last post by:
Hi, On a webpage I'm authoring I'm having a problem with setting the text background colour. I'm using this: P {color ="FFFFFF"; background-color:"000000"; font-size:10pt; font-family:...
9
by: al jones | last post by:
Sorry, it's getting late and I'm tired. I'm trying to fill a richtect box with text derived from the array I was asking about earlier (thank you). I'm not sure what I'm seeing - since most of...
0
by: H-S | last post by:
Can anyone help. I have a C# app developped in C# Express. I have a form which contains several groupboxs, with text labels. I also have a standard "label" on the form. I want to set the label...
1
Dököll
by: Dököll | last post by:
Greetings, Good buddies! I am for the first time, since I started learning VB, going to build an application I wanted to build for my first son, a language and activities program that will allow...
8
by: Dave Rado | last post by:
Hi Roderik On 15 Apr, 23:44, Roderik <nos...@atall.nlwrote: The image's position is defined relative to the right hand edge of the text, and depending on the what fonts the user has...
0
by: Gouri.Mahajan7 | last post by:
Hello, I want to change the font of the text in richtextbox without affecting the colour of text. I want some text to be printed in different colours. When I try to change the font of the text...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.