Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > DHTML in Netscape

Reply
Thread Tools

DHTML in Netscape

 
 
WJ
Guest
Posts: n/a
 
      11-01-2004
I have some DHTML that is showing and hiding a div. This works in IE and
Firefox, but not in Netscape.

<html>
<head>
<script language="javascript">
function switchDisplay()
{
if (myDiv.style.display=='block')
myDiv.style.display='none';
else
myDiv.style.display='block';
}
</script>
</head>
<body>
<form myform. . . >
<myDiv style="display:block">
blah
</myDiv>
<input type="button" value="test me" onclick="javascript:
switchDisplay();">
</form>


</body>
</html>

In the javascript, I can refer to the div directly in IE and Firefox (and
Mozilla). It does nothing in Netscape.

I've tried document.myDiv.style.display,
document.elements['myDiv'].style.display, and trying to walk the DOM through
the form.

Any suggestions would be greatly appreciated.

Thx!


 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      11-01-2004
WJ wrote:

> I have some DHTML that is showing and hiding a div. This works in IE and
> Firefox, but not in Netscape.


Netscape what? 3 or less? 4.x? or 6 and above?

3 doesn't do "DHTML".
4 is a buggy nightmare with dwindling market hare and not worth worrying
about.
6 should support pretty much anything any other Gecko based browser
supports.

> <html>
> <head>
> <script language="javascript">


The Language attribute is deprecated, and the type attribute is required.

> function switchDisplay()
> {
> if (myDiv.style.display=='block')


What is "myDiv"? You need to use document.getElementById (or document.all
for ancient versions of IE, or goodness knows what for Netscape 4) to get
an object reference first.

> <myDiv style="display:block">


There is no "myDiv" element in HTML.

> <input type="button" value="test me" onclick="javascript:
> switchDisplay();">


Loose the "javascript:" bit.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
 
Toby Inkster
Guest
Posts: n/a
 
      11-01-2004
WJ wrote:

> I have some DHTML that is showing and hiding a div. This works in IE and
> Firefox, but not in Netscape.


What do you mean by "Netscape"? There are significant differences between,
say, Netscape 4.08 and Netscape 7.1.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
WJ
Guest
Posts: n/a
 
      11-01-2004


Most humble apologies. I'm trying this with Netscape 7.2 The Div is
<div name="myDiv" id="myDiv" style="display:block">

.. . .

</div>



 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      11-01-2004
WJ wrote:

> function switchDisplay()
> {
> if (myDiv.style.display=='block')
> myDiv.style.display='none';
> else
> myDiv.style.display='block';
> }


Function should read:

function switchDisplay() {
myDiv = document.getElementById('myDiv');
if (myDiv.style.display=='block') myDiv.style.display='none';
else myDiv.style.display='block';
}

> <div name="myDiv" id="myDiv" style="display:block">
> . . .
> </div>


HTML should read:

<div id="myDiv">...</div>

The other attributes style/name are not needed.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
DU
Guest
Posts: n/a
 
      11-04-2004
WJ wrote:
> Most humble apologies. I'm trying this with Netscape 7.2 The Div is
> <div name="myDiv" id="myDiv" style="display:block">
>
> . . .
>
> </div>
>
>
>


There is no name attribute for div elements. Also, I recommend to never
use the same identifier for name and id attributes.
As mentioned by others, style="display:block" is also pointless as this
is the default display declaration in all CSS-capable browsers.

DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.3
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Netscape 7.1 to Netscape 8 Skid Schermerhorn Firefox 2 09-05-2005 04:04 PM
Do any DHTML books cover contemporary DHTML? Steve Javascript 1 04-09-2005 04:16 PM
Netscape with JRE 1.5 beta 1 ignores Netscape signing Mickey Segal Java 1 05-21-2004 01:52 PM
Netscape DHTML not working Catherine Lynn Smith Javascript 1 10-14-2003 02:24 PM
websphere, oracle, netscape: netscape timeout Tom Java 0 08-01-2003 11:03 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57