...

View Full Version : Using Style object on NS 4.x! Please help!!!



tuyle
07-11-2002, 12:51 PM
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

Soldier Bob
07-11-2002, 05:35 PM
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?



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

tuyle
07-12-2002, 04:02 AM
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

joh6nn
07-12-2002, 04:12 AM
this is a cross browse way to get to HTML elements, and their styles.

http://www.xs4all.nl/~ppk/js/dhtmloptions.html

tuyle
07-12-2002, 05:22 AM
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

:(

joh6nn
07-12-2002, 10:38 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum