By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,380 Members | 1,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,380 IT Pros & Developers. It's quick & easy.

More Netscape 7 problems

P: n/a

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:te***@testing.net">te***@testing.net</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,
in*****@stadmek.no

Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Ingmund Sjåstad" <in*****@sjaastad.no> wrote in message
news:r1*******************@news4.e.nsc.no...
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.
<html> <snip> <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.
Jul 20 '05 #2

P: n/a
"Ingmund Sjåstad" wrote:
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:te***@testing.net">te***@testing.net</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,
in*****@stadmek.no


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-deve...upgrade_2.html /> for tips
on converting document.all/document.layer constructs to the new method(s).

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #3

P: n/a
DU
Ingmund Sjåstad wrote:
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

<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;
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:te***@testing.net">te***@testing.net</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,
in*****@stadmek.no



DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #4

P: n/a
DU wrote:
<snip>
... 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
Jul 20 '05 #5

P: n/a
Dom Leonard wrote:
DU wrote:
<snip>
... 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


"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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_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-deve...upgrade_2.html
Jul 20 '05 #6

P: n/a
Grant Wagner wrote:
<snip>

"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
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.