473,382 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Hiding CSS class from Netscape 4.x

I'm trying to do a show/hide of several elements on a page and can't
get it working in Netscape 4.x. All other Windows browsers are
working.

My elements all have the same class name. <div
class="myClassName">stuff</div>
I cannot use ID because I don't know how many will appear as they are
dynamic recordsets. Netscape seems to work OK with IDs but not CSS
classes.

For Netscape 4.x I have coded in my javascript:
document.myClassName.visibility = "hide"; to hide it and
document.myClassName.visibility = "show"; to show it.

My CSS for this function is:

<style type="text/css">
..myClassName {visibility:hidden;}
</style>

When I use the toggle I get this error: document.myClassName has no
properties.

Any suggestions? Right now we are considering having standards-aware
browsers use client-side show/hide ( via
document.getElementsByTagName() ) and forcing Netscape 4.x to reload
the page, but would prefer to do it all in the browser.
Jul 20 '05 #1
8 2403
tr********@excite.com (TravelMan) wrote in
news:ca**************************@posting.google.c om:
I'm trying to do a show/hide of several elements on a page and
can't get it working in Netscape 4.x. All other Windows browsers
are working.


Why not hide all CSS from Netscape 4.x and provide Structural Markup?
You can't support buggy browsers for ever...

How to hide CSS from buggy browsers
http://w3development.de/css/hide_css_from_browsers/

--
Kayode Okeyode
http://www.kayodeok.co.uk/weblog/
Jul 20 '05 #2
TravelMan wrote:
I'm trying to do a show/hide of several elements on a page and can't
get it working in Netscape 4.x. All other Windows browsers are
working.
Sorry, but I really doubt that the below is working with *any* user agent.
For Netscape 4.x I have coded in my javascript:
document.myClassName.visibility = "hide"; to hide it and
document.myClassName.visibility = "show"; to show it.

My CSS for this function is:

<style type="text/css">
..myClassName {visibility:hidden;}
Is the `..' a typo? If not, remove one dot.
</style>

When I use the toggle I get this error: document.myClassName has no
properties.


You cannot reference CSS classes like objects. Instead, iterate
through the collection of DIV elements (use document.getElementsByName,
document.getElementsByTagName or document.layers, depending on the DOM[1])
and change the `className' property of each element to the name of a
CSS class where the `visibility' property has the value of `show'.
F'up2 cljs

PointedEars
___________
[1] Possibly you find http://pointedears.de.vu/scripts/dhtml.js useful
in this regard.

Jul 20 '05 #3
> and change the `className' property of each element to the name of a
CSS class where the `visibility' property has the value of `show'.


Why is that better than using JavaScript to change the CSS property?
I'm just curious because I saw that method elsewhere [on the MSDN] and found
it quite interesting. Is it really better? You're still using JavaScript
either way.

Thanks,
Nicko.
Jul 20 '05 #4


TravelMan wrote:
I'm trying to do a show/hide of several elements on a page and can't
get it working in Netscape 4.x. All other Windows browsers are
working.

My elements all have the same class name. <div
class="myClassName">stuff</div>
I cannot use ID because I don't know how many will appear as they are
dynamic recordsets. Netscape seems to work OK with IDs but not CSS
classes.

For Netscape 4.x I have coded in my javascript:
document.myClassName.visibility = "hide"; to hide it and
document.myClassName.visibility = "show"; to show it.

My CSS for this function is:

<style type="text/css">
.myClassName {visibility:hidden;}
</style>

When I use the toggle I get this error: document.myClassName has no
properties.

Any suggestions? Right now we are considering having standards-aware
browsers use client-side show/hide ( via
document.getElementsByTagName() ) and forcing Netscape 4.x to reload
the page, but would prefer to do it all in the browser.


Are those <div> elements positioned absolutely or statically with CSS?
If not forget about manipulating them with script as NN4 only makes
positioned elements available in its DOM.
If the <div>s are positioned then they should appear in
document.layers
and you can loop through document.layers
for (var i = 0; i < document.layers.length; i++)
document.layers[i].visibility = 'hide';
However if you wanted to check the class attribute of such a layer you
can't so you need to use other means to identify that a layer belongs to
a class, some way is to use an id attribute of the form
<div id="myClass01">
then you can check
document.layers[i].id.indexOf('myClass') == 0
to find out whether a layer belongs to your class.

Of course it is doubtful whether Netscape 4 is still worth the efforts,
some static functioning HTML page should suffice for Netscape 4 users.
--

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

Jul 20 '05 #5
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote in message news:<3F**************@PointedEars.de>...
TravelMan wrote:
I'm trying to do a show/hide of several elements on a page and can't
get it working in Netscape 4.x. All other Windows browsers are
working.


Sorry, but I really doubt that the below is working with *any* user agent.
For Netscape 4.x I have coded in my javascript:
document.myClassName.visibility = "hide"; to hide it and
document.myClassName.visibility = "show"; to show it.

My CSS for this function is:

<style type="text/css">
..myClassName {visibility:hidden;}


Is the `..' a typo? If not, remove one dot.
</style>

When I use the toggle I get this error: document.myClassName has no
properties.


You cannot reference CSS classes like objects. Instead, iterate
through the collection of DIV elements (use document.getElementsByName,
document.getElementsByTagName or document.layers, depending on the DOM[1])
and change the `className' property of each element to the name of a
CSS class where the `visibility' property has the value of `show'.
F'up2 cljs

PointedEars
___________
[1] Possibly you find http://pointedears.de.vu/scripts/dhtml.js useful
in this regard.


How do you get a handle on the className for a DIV when
getElementsByTagName doesn't work in NN4.x? Is there another way to
get the className for a DIV or a layer?
Jul 20 '05 #6
TravelMan wrote:
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote in message
news:<3F**************@PointedEars.de>...
It is called attribution _line_.
TravelMan wrote:
[...]
> <style type="text/css">
> ..myClassName {visibility:hidden;}


Is the `..' a typo? If not, remove one dot.
> </style>
>
> When I use the toggle I get this error: document.myClassName has no
> properties.


You cannot reference CSS classes like objects. Instead, iterate
through the collection of DIV elements (use document.getElementsByName,
document.getElementsByTagName or document.layers, depending on the DOM[1]) ^^^^^^^^^^^^^^^ and change the `className' property of each element to the name of a
CSS class where the `visibility' property has the value of `show'.
[...]


How do you get a handle on the className for a DIV when
getElementsByTagName doesn't work in NN4.x?


See above. The document.layers[...] collection allows for referencing
positioned layers.
Is there another way to get the className for a DIV or a layer?


Sorry, NS4-DOM seems not to provide a className property,
so referenceToLayer.visibility is the only way.
(again!) followup-to comp.lang.javascript

PointedEars

P.S.: Please don't quote what you are not referring to.

Jul 20 '05 #7
Can you recommend any good books on the DOM and DOM scripting? I'm new
to using that and already am impressed by the power of what it offers.
Thanks.
Jul 20 '05 #8
TravelMan wrote:
Can you recommend any good books on the DOM and DOM scripting?
follow from here: http://www.w3.org/DOM/
I'm new
to using that and already am impressed by the power of what it offers.


just be sure you ensure your pages work in UAs without script support e.g.
googlebot.

--
William Tasso - http://WilliamTasso.com
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Code Monkee | last post by:
How can the toolbar and menubar be hidden in IE? When opening the window via javascript I can specify 'toolbar=no,menubar=no', which works fine. However if the window already exists how can I...
6
by: TravelMan | last post by:
I'm trying to do a show/hide of several elements on a page and can't get it working in Netscape 4.x. All other Windows browsers are working. My elements all have the same class name. <div...
11
by: Lorenzo Villari | last post by:
I premise I don't know C++ well but... I wondered what is this data hiding thing... I mean, if I can look at the header (and i need it beacuse of the class), then what's hidden? Can someone give...
1
by: comp.lang.javascript | last post by:
Using IE5.5+, is it possible to hide options in a select? The following doesn't work: <HTML> <HEAD> <STYLE> SELECT OPTION.orgA{ display:none } .orgB{ display:inline } .orgC{ display:none }
9
by: middletree | last post by:
I'm doing an ASP-built Intranet app, and am having trouble with a bit of code on the menu I am using. I got it from some free site, but I tried emailing the person whose email address is in the...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
9
by: bob | last post by:
Hi, I know there exists a good reason why the designers of c++ decided that function hiding should exist. But I don't know why. Can anybody provide a good reason/example of a case where function...
3
by: Nicolas Castagne | last post by:
Hi all, I have been wondering for a while why function hiding (in a derived class) exists in C++, e.g. why when writing class Base { void foo( int ) {} }; class Derived: public Base { void...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.