Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / March 2007



Tip: Looking for answers? Try searching our database.

Control font color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mistral - 25 Mar 2007 14:57 GMT
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
Jukka K. Korpela - 25 Mar 2007 17:11 GMT
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.

Signature

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

mistral - 25 Mar 2007 17:58 GMT
> Scripsit mistral:
>
[quoted text clipped - 27 lines]
> --
> Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
-----------

thank you.

mistral
Osmo Saarikumpu - 25 Mar 2007 18:07 GMT
> 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
mistral - 25 Mar 2007 23:44 GMT
> > 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
---------
OK, I forget about that script..  Here a new code that fully comply
all HTML/CSS standards.
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). To remove background and border, it
seems, i  just need remove border, padding, background attributes from
div.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Typewriter Example</title>
</head>

<body>

<h1>Typewriter Effect Example</h1>

<script type="text/javascript">

function Typewriter(sName)
{    // PROPERTIES
    this.counter = 0;
    this.name = sName;
    this.text = "";
    this.speed = 50; // in milliseconds

    // METHODS
    this.addText = AddText;
    this.next = Next;
    this.setSpeed = SetSpeed;
    this.write = Write;

    // FUNCTIONS
    function AddText(s)
    {    this.text = s
    }
    function Next()
    {    document.getElementById('typewriter_output').innerHTML =
this.text.substr(0, this.counter++);
    }
    function SetSpeed(iSpeed)
    {    this.speed = iSpeed;
    }
    function Write()
    {    setInterval(this.name+".next()",this.speed);
    }
}

</script>

<div id="typewriter_output" style="width:400px;border:1px black
solid;padding:1em;background:#f3f3f3;"></div>

<script type="text/javascript">
var myTypewriter = new Typewriter("myTypewriter");
myTypewriter.addText("Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Suspendisse eu nisi nec nunc tempor pharetra. Morbi
viverra. Proin scelerisque.");
myTypewriter.write();
</script>

</body>
</html>

mistral
Osmo Saarikumpu - 26 Mar 2007 17:44 GMT
> 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.

> 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.

> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.