473,395 Members | 1,608 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,395 software developers and data experts.

How do you REALLY toggle visibility in Netscape (using 7.1 right now)

Hi,

I've read through quite a number of postings on here so far and have
seen what look like very simply, reasonable answers to this question,
however I am still completely unable to do what I want to do.

I just want to know how I should toggle the visibility of divs in
Netscape (I'm using 7). For example, say I have the following HTML
code:
<a href='javascript:showMyDiv();'>Show mydiv</a>

<div id='mydiv' style='visibility:hidden;'>
This text does not appear when I load the page in Netscape, so I know
it recognizes the 'visibility:hidden;' part of the above tag.
</div>

However, when I click on the link (coded as above), the following
javascripts do not make the div appear. It works fine in Explorer.
<script>
function showMyDiv()
{
mydiv.style.visibility = "visible"; // Works in IE, not Netscape
document.mydiv.style.visibility = "visible"; // Ditto

// THE FOLLOWING WERE SUGGESTED, BUT NONE OF THEM WORK FOR ME
document.mydiv.style.visibility = "show";
document.mydiv.visibility = "show";
document.mydiv.style.visibility = "visible";
document.mydiv.visibility = "visible";
document.mydiv.display = "";
document.mydiv.style.display = "";
}
</script>

Can anyone tell me what the syntax really SHOULD be?

Eternal thanks in advance.

- Jon
Jul 20 '05 #1
4 2799
Jonathan wrote:
<a href='javascript:showMyDiv();'>Show mydiv</a>

<div id='mydiv' style='visibility:hidden;'>

However, when I click on the link (coded as above), the following
javascripts do not make the div appear. It works fine in Explorer.

mydiv.style.visibility = "visible"; // Works in IE, not Netscape

Can anyone tell me what the syntax really SHOULD be?


document.getElementById('mydiv').style.visibility = 'visible';
Jul 20 '05 #2
Ivo
"Leif K-Brooks" wrote:
Jonathan wrote:
<a href='javascript:showMyDiv();'>Show mydiv</a>

<div id='mydiv' style='visibility:hidden;'>

However, when I click on the link (coded as above), the following
javascripts do not make the div appear. It works fine in Explorer.

mydiv.style.visibility = "visible"; // Works in IE, not Netscape

Can anyone tell me what the syntax really SHOULD be?


document.getElementById('mydiv').style.visibility = 'visible';


or even:
if( document.getElementById && document.getElementById )
{ document.getElementById('mydiv').style.visibility = 'visible'; }

Also, it may be worth repeating that 'javascript:' as the href of an <a> tag
should be avoided, unless you wish to present a bookmarklet. The link SHOULD
really look something like:

<a href="nojs.html" onclick="return showMyDiv();">Show mydiv</a>

and the function should explicitely return a boolean *false* value to stop
the href to the non-javascripted alternative resource being followed.
Better still is of course to dynamically document.write() the link to
prevent the javascriptless from seeing it in the first place.

--
Iv
Jul 20 '05 #3
Jonathan wrote:
<a href='javascript:showMyDiv();'>Show mydiv</a>
That's a rather bogus construct. What does this "link" do when js is
disabled? You're better off with "onClick" set to an element that is
only created via JavaScript. Thus, when it's disabled, there's nothing
there. When it's enabled, there's a button or some such thing that
toggles the visability of the div.
However, when I click on the link (coded as above), the following
javascripts do not make the div appear. It works fine in Explorer.

<script> function showMyDiv()


You've already got the answer you need. You might want to ask in a
javascript group next time, as this group is for html.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #4
Ivo wrote:
or even:
if( document.getElementById && document.getElementById )


Errrr.... huh? I presume there's a typo there, as:

A && A == A

--
Mark.
Jul 20 '05 #5

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

Similar topics

1
by: Ahmad Noori | last post by:
I have a form and in the form, I have a drop down box. Based on what the user selects, i want to display different input boxes. Here is my drop down box: <td> <select name="reptype"...
3
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
11
by: Tery Griffin | last post by:
who can't get onload to fire at all in IE on a Mac? Iım about to try the suggestion of adding the script after the body tag. Iıd really rather do it some ³right² way, if thereıs a right way that...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
1
by: Keith Harris | last post by:
Hi, I have a Repeater control which is bound to a dataset. In the footer of the repeater control, I have a Button whose visibility I want to vary according to the sum of a column being > 0. ...
3
by: Dica | last post by:
i want to set up my aspx page with a hierarchical navigation system. first the user has to select to "-- Select An Action --", which could be either "Add Item" or "Edit Item". If the user selects...
4
by: Jon | last post by:
I'm looking for a way to toggle text without using client scripting. One way to go is by the visibility property and a click event, but this does a postback and returns to the top of the page. Is...
2
by: celoftis | last post by:
Using VS2005, ASP.NET. Check out the tree view on this page: http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.aspx When you hover over the border between the two...
1
by: swiftouch | last post by:
I'm getting an error message in FF2.0: document.getElementById(toggle) has no properties The goal of the script is, when I hover my mouse over an image, to make one div element visible while...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.