text colour

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff

    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
  • Ivo

    #2
    Re: text colour

    "Geoff" wrote[color=blue]
    > 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.[/color]

    You could indeed add "<span style='color:ye llow;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:
    <

    ml >

    hth
    --
    ivo





    Comment

    • Mick White

      #3
      Re: text colour

      Geoff wrote:[color=blue]
      > 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.[/color]


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

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

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

      Mick

      Comment

      • Geoff

        #4
        Re: text colour

        Geoff wrote:
        [color=blue]
        > 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[/color]



        Thanks for your advice guys.

        Geoff

        Comment

        Working...