Web Analytics Made Easy -
StatCounter Using Style object on NS 4.x! Please help!!! - CodingForum

Announcement

Collapse
No announcement yet.

Using Style object on NS 4.x! Please help!!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Style object on NS 4.x! Please help!!!

    Hello,

    Anyone know how to use object Style in NS 4.x and how to access the
    properties of it? If you can, please give me an example.

    I have a table, in which, I use style sheet to format a table row:

    <html>
    <head>
    <style type="text/css">
    .trStyle1 {background-color: #FFFF00;}
    .trStyle2 {background-color: #FCFCD6;}
    </style>
    </head>

    <body>
    <table width=100 border=1 cellspacing=0 cellpadding=0>
    <tr class="trStyle1">
    <td>Some information here......</td>
    </tr>
    </table>
    </body>
    </html>

    Can I change the style of TR from "trStyle1" to "trStyle2" on NS 4.x? Or any
    way to change new properties (example background color) of TR?
    I don't want to use document.write("<table width=100 border=1 cellspacing=0 cellpadding=0>" +
    " <tr class="trStyle2">"+
    " <td>Some information here......</td>"+
    " </tr>"+
    " </table>");

    to change TR's properties.



    I use document.classes to create Style object like that:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <style type="text/javascript">
    classes.GreenBody.all.backgroundColor="green"
    </style>
    <script>
    function load() {
    alert(document.classes.GreenBody.all.backgroundColor);
    document.classes.GreenBody.all.backgroundColor="cyan";
    alert(document.classes.GreenBody.all.backgroundColor);
    }
    </script>
    <body bgcolor="#FFFFFF" text="#000000" onLoad="load()">
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
    <tr class="GreenBody">
    <td>Hehehehe</td>
    </tr>
    </table>
    </body>
    </html>

    The default background color of TR is green. I want after loading, change
    it's color from GREEN to BLUE. It seems that the background color is
    changed, but on browers, nothing happens.

    Thanks for help,
    Tuy Le

  • #2
    ns 4.x ?

    you may have to use the rewrite... I think I was stuck on this problem as well. Getting the an image to change in IE but not NS 4.x

    I dont know if I am actually getting to the attribute or not.

    [JSSTag] - anyone know what this is?

    Code:
    <html>
    <head>
    <script type="text/javascript" language="javascript">
      function swap_color() {
    if (document.classes.trStyle2.backgroundColor) {
      alert("Debug: the is a classes object: " + document.classes.trStyle2.backgroundColor);
    }
    
        if (document.all) {
        //IE - older
          
        } else if (document.layers) {
          //ns 4.x
          document.classes.trStyle2.backgroundColor = 'red';
        }
      }
    </script>
    
    <style type="text/css">
     .trStyle1 {
                 position: absolute;
                 background-color: #FFFF00;
               }
     .trStyle2 {
                 
                 background-color: #FCFCD6;
                 top: 50;
                 left: 50;
                 width: 200;
                 height: 100;
               }
    </style>
    
    </head>
    
    <body>
      <table width=100 border=1 cellspacing=0 cellpadding=0>
        <tr class="trStyle2">
          <td>Some information here......</td>
        </tr>
      </table>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <form name="frmTest" action="javascript:void(0);" method="post">
      <input type="button" value="Change color" onclick="swap_color();">
    </form>
    </body>
    </html>
    Last edited by Soldier Bob; Jul 11, 2002, 11:37 AM.

    Comment


    • #3
      Hello,

      Thanks for your reply.

      I think [JSSTag] is Style object, defined by NS Java Script. It has lot of properties as you may know

      However, when I chang its properties, I see that its properties have been changed but nothing happen on the browser. Maybe NS can not auto refresh after changing

      Cheers,
      Tuy Le

      Comment


      • #4
        this is a cross browse way to get to HTML elements, and their styles.

        bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

        i am a loser geek, crazy with an evil streak,
        yes i do believe there is a violent thing inside of me.

        Comment


        • #5
          Hello joh6nn,

          I have tried the URL you gave, but the example just runs well with IE. Have you ever tried this with NN4?

          Thanks

          Comment


          • #6
            no, i don't have NS4, so i've never been able to test it NS. that comes from a really well respected JavaScript expert, though, so i've taken it for granted that the thing works.
            bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

            i am a loser geek, crazy with an evil streak,
            yes i do believe there is a violent thing inside of me.

            Comment

            Working...
            X