body.style.fontWeight problem

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

    #1

    body.style.fontWeight problem

    Hi,

    The JavaScript underneath makes _one_ tab bold while the others receive
    the 'none' CSS property. This works in a frameless page, and has
    always worked. However, my current project _requires_ me to use frames
    :-( (leftFrame, topFrame and mainFrame) and when I tested this script in
    frames, it gave me a "invalid property" error. What can I do?

    Thanks in advance,

    Alain

    --- EXAMPLE ---
    <html>
    <head>
    <script language='JavaS cript'>
    function tabMe()
    {
    document.body.s tyle.fontWeight ="none"
    this.style.font Weight="bold"
    }
    </script>
    </head>
    <body>
    <a href="bio.htm" onClick="tabMe( )">Bio</a> | <a href="film.htm"
    onClick="tabMe( )">Films</a> | <a href="contact"
    onClick="tabMe( )">Contact</a>
    </body>
    --- EXAMPLE ---

  • Martin Honnen

    #2
    Re: body.style.font Weight problem



    Alain wrote:

    [color=blue]
    > when I tested this script in
    > frames, it gave me a "invalid property" error. What can I do?[/color]
    [color=blue]
    > --- EXAMPLE ---
    > <html>
    > <head>
    > <script language='JavaS cript'>
    > function tabMe()[/color]

    I guess you want
    function tabMe (element) {[color=blue]
    > {
    > document.body.s tyle.fontWeight ="none"
    > this.style.font Weight="bold"[/color]
    and then
    element.style.f ontWeight = "bold"
    although I would suggest to use
    if (element.style) {
    element.style.f ontWeight = "bold";
    }
    to avoid errors in Netscape 4 for instance.
    [color=blue]
    > }
    > </script>
    > </head>
    > <body>
    > <a href="bio.htm" onClick="tabMe( )">Bio</a> | <a href="film.htm"
    > onClick="tabMe( )">Films</a> | <a href="contact"
    > onClick="tabMe( )">Contact</a>
    > </body>
    > --- EXAMPLE ---
    >[/color]

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...