More Netscape 7 problems

I

Ingmund Sjåstad

Trying to make a dropdown menu. I working nice in IE6 but when I try a link
in Netscape 7 nothing happens.
Can anybody help me?

<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JS</title>
</head>
<body>

<script language="JavaScript" type="text/JavaScript">

var px="px";

function getStyle(elemName) {
var elem;
if (document.getElementById) { elem=document.getElementById(elemName);}
else if (document.all) { elem=document.all[elemName];}
else if (document.layers) { elem=document.layers[elemName]; px="";}
else {return null;}

if (!elem.style) {
return elem;
}
return elem.style;
}

function hideElement(elemName) {
var style=getStyle(elemName);
if (style) {
style.visibility="hidden";
style.width=1+px;
style.height=1+px;
}
}

function showElement(elemName) {
var style=getStyle(elemName);
if (style) {
style.visibility="visible";
style.width=150+px;
style.height=80+px;
}
}

</script>

<br><br>

<a href="javascript:hideElement('test')">
<div style="position:absolute; z-index:1; left: 25px; top: 10px;"
border="0" onMouseOver="showElement('test')"
onMouseOut="hideElement('test')">
<strong>Meny<strong>
</div>
</a>

<div id="test" style="position:absolute; z-index:1; left: 25px; top: 31px;
width: 0px; height: 0px; background-color: white; overflow: hidden"
onClick="hideElement('test')" onMouseOver="showElement('test')"
onMouseOut="hideElement('test')">
<a href="mailto:[email protected]">[email protected]</a><br>
<a href="http://groups.google.com">Google groups</a><br>
<a href="http://www.yahoo.com">Yahoo</a>
</div>

</body>
</html>
 
R

Richard Cornford

Ingmund Sjåstad said:
Trying to make a dropdown menu. I working nice in
IE6 but when I try a link in Netscape 7 nothing happens.
Can anybody help me?

For me that test page works exactly the same in Netscape 7.00, 7.02 and
Mozilla 1.3 as it does in IE 6.
<a href="javascript:hideElement('test')">
<snip>

Weren't you told not to use the javascritp pseudo protocol to execute
JavaScript functions as a side effect?

< URL: http://jibbering.com/faq/#4_24 >

Richard.
 
G

Grant Wagner

Ingmund Sjåstad said:
Trying to make a dropdown menu. I working nice in IE6 but when I try a link
in Netscape 7 nothing happens.
Can anybody help me?

<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JS</title>
</head>
<body>

<script language="JavaScript" type="text/JavaScript">

var px="px";

function getStyle(elemName) {
var elem;
if (document.getElementById) { elem=document.getElementById(elemName);}
else if (document.all) { elem=document.all[elemName];}
else if (document.layers) { elem=document.layers[elemName]; px="";}
else {return null;}

if (!elem.style) {
return elem;
}
return elem.style;
}

function hideElement(elemName) {
var style=getStyle(elemName);
if (style) {
style.visibility="hidden";
style.width=1+px;
style.height=1+px;
}
}

function showElement(elemName) {
var style=getStyle(elemName);
if (style) {
style.visibility="visible";
style.width=150+px;
style.height=80+px;
}
}

</script>

<br><br>

<a href="javascript:hideElement('test')">
<div style="position:absolute; z-index:1; left: 25px; top: 10px;"
border="0" onMouseOver="showElement('test')"
onMouseOut="hideElement('test')">
<strong>Meny<strong>
</div>
</a>

<div id="test" style="position:absolute; z-index:1; left: 25px; top: 31px;
width: 0px; height: 0px; background-color: white; overflow: hidden"
onClick="hideElement('test')" onMouseOver="showElement('test')"
onMouseOut="hideElement('test')">
<a href="mailto:[email protected]">[email protected]</a><br>
<a href="http://groups.google.com">Google groups</a><br>
<a href="http://www.yahoo.com">Yahoo</a>
</div>

</body>
</html>

--

___________________________
Best Regards,
(e-mail address removed)

Netscape 7 supports neither document.all (proprietary to IE and a couple other
browsers) nor document.layers (proprietary to Netscape 4.x).

You should be using document.getElementById() to access DOM items.

See <url: http://www.mozilla.org/docs/web-developer/upgrade_2.html /> for tips
on converting document.all/document.layer constructs to the new method(s).

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
D

DU

Ingmund said:
Trying to make a dropdown menu. I working nice in IE6 but when I try a link
in Netscape 7 nothing happens.
Can anybody help me?

<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

The doctype declaration should be the very first statement of your
webpage. I also strongly recommend that you use 4.01 and a strict DTD here.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title>Title goes here</title>


<title>JS</title>
</head>
<body>

<script language="JavaScript" type="text/JavaScript">

language is a deprecated attribute. Type has replaced lagnuage and is
both backward and forward-compatible, so you can not be wrong with

var px="px";

function getStyle(elemName) {
var elem;
if (document.getElementById) { elem=document.getElementById(elemName);}
else if (document.all) { elem=document.all[elemName];}
else if (document.layers) { elem=document.layers[elemName]; px="";}
else {return null;}

if (!elem.style) {
return elem;
}
return elem.style;
}

function hideElement(elemName) {
var style=getStyle(elemName);
if (style) {
style.visibility="hidden";
style.width=1+px;
style.height=1+px;

Why do you change the width and height when hiding or making visible an
element?
}
}

function showElement(elemName) {
var style=getStyle(elemName);
if (style) {
style.visibility="visible";
style.width=150+px;
style.height=80+px;
}
}

The above code is not complete or it's not logical. You are willing to
detect and support NS 4 (which is more than 6 years old) which uses
document.layers but you are not willing to use its "hide" and "show" for
the visibility of its DOM nodes.
</script>

<br><br>

<a href="javascript:hideElement('test')">

Do not use the "javascript:" pseudo-protocol in href attributes for many
reasons: it's bad, wrong, not recommendable,etc..

"javascript:" pseudo-protocol destroys right-click context menu.
Top Ten Web-Design Mistakes of 2002
6. JavaScript in Links:
(...) A link should be a simple hypertext reference that replaces the
current page with new content. (...) link is not a piece of code that
interferes with the browser’s standard behavior."
http://www.useit.com/alertbox/20021223.html

"Don't use javascript: URLs
Using a straight http: URL will allow any browser to access the link. If
you want to use JavaScript for browsers that have JavaScript enabled,
use the onMouseOver and onClick attributes of the <a href> tag."
http://www.rahul.net/aahz/javascript.html#remove

<div style="position:absolute; z-index:1; left: 25px; top: 10px;"
border="0" onMouseOver="showElement('test')"
onMouseOut="hideElement('test')">
<strong>Meny<strong>
</div>
</a>

<div id="test" style="position:absolute; z-index:1; left: 25px; top: 31px;
width: 0px; height: 0px; background-color: white; overflow: hidden"
onClick="hideElement('test')" onMouseOver="showElement('test')"
onMouseOut="hideElement('test')">
<a href="mailto:[email protected]">[email protected]</a><br>
<a href="http://groups.google.com">Google groups</a><br>
<a href="http://www.yahoo.com">Yahoo</a>
</div>

</body>
</html>

--

___________________________
Best Regards,
(e-mail address removed)

DU
 
D

Dom Leonard

DU wrote:
... You are willing to
detect and support NS 4 (which is more than 6 years old) which uses
document.layers but you are not willing to use its "hide" and "show" for
the visibility of its DOM nodes.

The last time I checked, "visible" and "hidden" values for visibility
worked in all NN4 browsers available for testing. AFAIK these included
4.72, 4.08, 4.06 and 4.01. Results lead me to believe that the
requirement for "hide" and "show" are urban myths originated by Netscape
in a document entitled
DYNAMIC HTML IN NETSCAPE COMMUNICATOR
COMMUNICATOR PRE-RELEASE 5
and perpetuated by script writers for Dreamweaver. Of course it is
possible the documentation was correct for NS4PR5, but who in the world
cares?

Cheers,
Dom
 
G

Grant Wagner

Dom said:
DU wrote:


The last time I checked, "visible" and "hidden" values for visibility
worked in all NN4 browsers available for testing. AFAIK these included
4.72, 4.08, 4.06 and 4.01. Results lead me to believe that the
requirement for "hide" and "show" are urban myths originated by Netscape
in a document entitled
DYNAMIC HTML IN NETSCAPE COMMUNICATOR
COMMUNICATOR PRE-RELEASE 5
and perpetuated by script writers for Dreamweaver. Of course it is
possible the documentation was correct for NS4PR5, but who in the world
cares?

Cheers,
Dom

"visible" and "hidden" work when setting layer visibility in Netscape 4.x.

When getting these values for testing purposes, Netscape 4.x returns "show" or
"hide".

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
D

Dom Leonard

Grant Wagner wrote:
"visible" and "hidden" work when setting layer visibility in Netscape 4.x.

When getting these values for testing purposes, Netscape 4.x returns "show" or
"hide".

thanks Grant,

I most certainly did not know the second piece of information.

Dom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top