Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-11-2002, 11:51 AM   PM User | #1
tuyle
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
tuyle is an unknown quantity at this point
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
tuyle is offline   Reply With Quote
Old 07-11-2002, 04:35 PM   PM User | #2
Soldier Bob
New Coder

 
Join Date: Jul 2002
Location: USA, East Coast
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Soldier Bob is an unknown quantity at this point
Netscape 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; 07-11-2002 at 04:37 PM..
Soldier Bob is offline   Reply With Quote
Old 07-12-2002, 03:02 AM   PM User | #3
tuyle
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
tuyle is an unknown quantity at this point
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
tuyle is offline   Reply With Quote
Old 07-12-2002, 03:12 AM   PM User | #4
joh6nn
wei wu wei


 
joh6nn's Avatar
 
Join Date: Jun 2002
Location: 72° W. 48' 57" , 41° N. 32' 04"
Posts: 1,887
Thanks: 0
Thanked 1 Time in 1 Post
joh6nn is an unknown quantity at this point
this is a cross browse way to get to HTML elements, and their styles.

http://www.xs4all.nl/~ppk/js/dhtmloptions.html
__________________
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.
joh6nn is offline   Reply With Quote
Old 07-12-2002, 04:22 AM   PM User | #5
tuyle
New to the CF scene

 
Join Date: Jun 2002
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
tuyle is an unknown quantity at this point
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

tuyle is offline   Reply With Quote
Old 07-12-2002, 09:38 AM   PM User | #6
joh6nn
wei wu wei


 
joh6nn's Avatar
 
Join Date: Jun 2002
Location: 72° W. 48' 57" , 41° N. 32' 04"
Posts: 1,887
Thanks: 0
Thanked 1 Time in 1 Post
joh6nn is an unknown quantity at this point
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.
joh6nn is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:18 PM.


Advertisement
Log in to turn off these ads.