HighDots Forums  

Control font color

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Control font color in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mistral
 
Posts: n/a

Default Control font color - 03-25-2007 , 09:57 AM






Simple question: how better set font color in script?

<script type="text/javascript">
<!--

//Secify scroller contents
var line=new Array()
line[1]="Typewriter script"
line[2]="It brings up the text you want..."
line[3]="One letter at a time"
line[4]="You can add and subtract lines as you like."
line[5]="It\'s very cool and easy to use"

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

//--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: verdana; font-size:
'+ts_fontsize+'; font-weight:normal; 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(){

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>

regards,
mistral


Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Control font color - 03-25-2007 , 12:11 PM






Scripsit mistral:

Quote:
Simple question: how better set font color in script?
This group discusses style sheets, not scripts. There's a connection of
course, but this seems to be well on the scripting side; try
comp.lang.javascript if you can't find the answer in the JavaScript
tutorials and references that you normally use or in the FAQs.

Quote:
document.write(' style="background-color: '+document.bgColor+';
color: '+document.body.text+'; font-family: verdana; font-size:
'+ts_fontsize+'; font-weight:normal; border: medium none"
onfocus="blur()">')
You seem to use the very old methods of changing a document via scripting;
the modern approach uses the W3C DOM and not document.write(). But if you
keep using the dated approach, generating HTML markup that contains a style
sheet embedded into an attribute, then you have a purely CSS question
indeed, though a very trivial one: how to set font color in _CSS_.

The answer is
color: black;
or
color: #000;
or
color: #000000;
to mention the most commonly used variants. Check CSS tutorials for more
details.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #3  
Old   
mistral
 
Posts: n/a

Default Re: Control font color - 03-25-2007 , 12:58 PM



"Jukka K. Korpela" <jkorp... (AT) cs (DOT) tut.fi> wrote:
Quote:
Scripsit mistral:

Simple question: how better set font color in script?

This group discusses style sheets, not scripts. There's a connection of
course, but this seems to be well on the scripting side; try
comp.lang.javascript if you can't find the answer in the JavaScript
tutorials and references that you normally use or in the FAQs.

document.write(' style="background-color: '+document.bgColor+';
color: '+document.body.text+'; font-family: verdana; font-size:
'+ts_fontsize+'; font-weight:normal; border: medium none"
onfocus="blur()">')

You seem to use the very old methods of changing a document via scripting;
the modern approach uses the W3C DOM and not document.write(). But if you
keep using the dated approach, generating HTML markup that contains a style
sheet embedded into an attribute, then you have a purely CSS question
indeed, though a very trivial one: how to set font color in _CSS_.

The answer is
color: black;
or
color: #000;
or
color: #000000;
to mention the most commonly used variants. Check CSS tutorials for more
details.

--
Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
-----------

thank you.

mistral



Reply With Quote
  #4  
Old   
Osmo Saarikumpu
 
Posts: n/a

Default Re: Control font color - 03-25-2007 , 01:07 PM



mistral wrote:

Quote:
Simple question: how better set font color in script?
Simple answer: replace following string:

color: '+document.body.text+';

with:

color:red;

Or create a variable, e.g. ScrollerTextColor and assign it a value:

var ScrollerTextColor = 'red';

and refer to it instead of document.body.text.

Even simpler answer: forget about that script. Them comments:

//if IE 4+ or NS6

are a hint of obsoleteness.

Osmo



Reply With Quote
  #5  
Old   
Osmo Saarikumpu
 
Posts: n/a

Default Re: Control font color - 03-26-2007 , 12:44 PM



mistral wrote:

Quote:
OK, I forget about that script.. Here a new code that fully comply
all HTML/CSS standards.
Please upload your code and provide an URL instead of sending code.

Quote:
What I want to correct - in fact, it consists of two scripts, that is
not convenient. I want join all in one script. I need also repeat
typewriter(set loop function).
Please note Mr. Korpela's advice concerning the correct group. You
should get the above mentioned aspects working before asking for
presentational help.

Quote:
To remove background and border, it
seems, i just need remove border, padding, background attributes from
div.
Yes. Remove, modify, apply presentation from elsewhere... these all are
more or less trivial matters to be attended after the script's
functionality.

Osmo


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.