#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    durban south africa
    Posts
    29
    Rep Power
    0

    Thumbs up Javascript and style sheets


    Hello
    Please help me.

    I declared a style sheet as follows.
    <STYLE type="text/css">

    .init {font-size:400%; font-weight:bold;display:none}


    </STYLE>

    When a user clicks on a button I want to change a property to something else eg. font-size to 200%.
    It works in IE but NS6 is giving problems.

    I coded in the onclick to go to javascript function.

    function showhide()

    {
    document.getElementById("menu1outline").class.font-size = 50%;

    }

    Please help
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    200
    Rep Power
    14
    I think it's:

    document.getElementById("menu1outline").style.fontSize = 50%;

    Yes, this works. Just tested it on NS6 and IE5.5.

    Two things:
    * your init style definition won't affect your menu1outline
    * what's with the .class? I've seen the class property before on this forum so I'm wondering... is there a site that says you have to use style sheets this way? Maybe there's some confusion about ID and CLASS?
    Last edited by Void; May 29th, 2001 at 05:20 AM.
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    durban south africa
    Posts
    29
    Rep Power
    0

    Unhappy Tried it , it does not work


    Thanx for the reply.
    I tried it and it does not work.

    Does it matter if the font size I'm trying to change belongs to a span tag ?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    200
    Rep Power
    14
    I also used a span tag.

    Could you post all the relevant code? Maybe you overlooked something else.
  8. #5
  9. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    durban south africa
    Posts
    29
    Rep Power
    0
    <STYLE type="text/css">

    .init {font-size:400%; font-weight:bold;}


    </STYLE>

    <script language="javascript">

    function showhide()

    {
    document.getElementById("menu1outline").style.fontSize = 50%;

    }

    </script>

    <body bgcolor="ivory">


    <span id="menu1" onClick="showhide();" >
    <img id="menu1sign" src="closed.gif" align="bottom">
    Mail Services
    </span><br>

    <span id="menu1outline" class="init">
    Havasen Reddy is from South Africa !

    </span>

    </body>
  10. #6
  11. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    durban south africa
    Posts
    29
    Rep Power
    0
    If u can't find the error would you mind posting the code u tested then I will run it on my machine and see how it runs on netscape 6.
    IE is no problem NS6 is !

    I am suffering here. Your help is the only one I can get.
    I searched the net for hours without succcess...
    Anxiously and eagerly awaiting your response....
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    200
    Rep Power
    14
    Just a sec... putting something together right now.
    Btw, you can also use #menu1outline instead of .init

    Oh, and put " " around 50%
    (fontStyle = "50%")

    here's my code

    <HTML>
    <HEAD>
    <TITLE>?</TITLE>

    <STYLE>
    .init
    {
    font-size:400%; font-weight:bold;
    }
    </STYLE>

    <SCRIPT LANGUAGE="javascript">
    function showhide()
    {
    document.getElementById("menu1outline").style.fontSize = "50%";
    }
    </SCRIPT>

    </HEAD>
    <BODY>

    <SPAN ID="menu1" onClick="showhide();">
    <IMG ID="menu1sign" SRC="closed.gif" ALIGN="bottom">Mail Services
    </SPAN>

    <BR>

    <SPAN ID="menu1outline" CLASS="init">TEXT</SPAN>

    </BODY>
    </HTML>
    Last edited by Void; May 29th, 2001 at 06:08 AM.
  14. #8
  15. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    durban south africa
    Posts
    29
    Rep Power
    0
    Thanx void.
    It works now.
    Apparently you have to have those " " around the 50%.
    Silly error from my side but many thanx for you helping me.
  16. #9
  17. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    Havasen & Void -

    you can change a element's class with script - you just need to reference the className property of the element. As noted below, the use of this is limited in NS6:

    http://www.faqts.com/knowledge_base/...d/3172/fid/128

IMN logo majestic logo threadwatch logo seochat tools logo