473,396 Members | 2,010 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,396 software developers and data experts.

Netscape 7

This scipt is working in IE6 but not in Netscape 7. What am I doin wrong?

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

var ns = false;
var ie = false;

ie = (document.all) ? true : false;
ns = (document.layers) ? true : false
function hideLayer(layerName) {
if (ie){
document.all(layerName).style.visibility="hidden";
document.all(layerName).style.width="16";
document.all(layerName).style.height="16";
} else if (ns) {
document.layers[layerName].visibility = "hide";
document.layers[layerName].width="16";
document.layers[layerName].height="16";
}
}

function showLayer(layerName) {
if (ie){
document.all(layerName).style.visibility="visible" ;
document.all(layerName).style.width="140";
document.all(layerName).style.height="400";
} else if (ns) {
document.layers[layerName].visibility = "show";
document.layers[layerName].width="140";
document.layers[layerName].height="400";
}
}

</script>
--

___________________________
Best Regards,

Ingmund Sjåstad
in*****@stadmek.no

Jul 20 '05 #1
7 2371
Ingmund Sjåstad wrote:
This scipt is working in IE6 but not in Netscape 7. What am I doin wrong? ie = (document.all) ? true : false;
ns = (document.layers) ? true : false
document.all(layerName).style.width="16";


(1) You are detecting a single feature of IE or NS rather then performing
object detection for every feature you wish to use.

(2) You are using an MSIE specific feature to detect IE and a NS 4.x
specific feature to detect NS.

Modern browsers (NS6+, Mozilla, IE (5+?), Opera etc) use the W3C DOM.
document.getElementById('id_of_element').

(3) You are forgetting the units on your lengths

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #2
Lasse Reichstein Nielsen wrote:
"Ingmund Sjåstad" <in*****@sjaastad.no> writes:

This scipt is working in IE6 but not in Netscape 7. What am I doin wrong?

You have a script that attempts to detect IE and Netscape 4, and only
in those cases does it do anything. Since Netscape 7 is not IE or
Netscape 4, it does exactly what it is being asked to do: nothing.
Pedantically, I would say that the script works. It just doesn't do
what you expect.

The code isn't very pretty either, with lots of repeated
subexpressions, so here is an alternative: (I dislike using the word
"layer" about something not created with the <layer> tag, so I renamed
the functions too. I consider it artistic license :)

<script type="text/javsscript">
var px="px";
function getStyle(elemName) {
var elem;
if (document.getElemenetById) { elem=document.getElementById(elemName);}


Spotted the deliberate mis^take !
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=16+px;
style.height=16+px;
}
}

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

</script>

Untested code!

This is not perfect, there are browsers without document.layers that
don't want "px" after the lengths (e.g., Opera 6). Netscape 7 requires
the "px" in standards mode (and you shouldn't write new pages to Quirks
mode!)

It is not necessary to use "show" and "hide" for Netscape 4, it
understands "visible" and "hidden" fine. It just converts them to
"show" and "hide" internally, so if you read the value back, it will
be the four letter one. (Tested in NS4.08/Win)

/L


Jul 20 '05 #3
Chris Sharman <ch***********@sorry.nospam> writes:
Lasse Reichstein Nielsen wrote:
if (document.getElemenetById) { elem=document.getElementById(elemName);}
Spotted the deliberate mis^take !


Yes, very good. And it was ofcourse deliberate. Surely. Absolutely!
Untested code!


*cough*

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
I have now tried this, but it is still not working in Netscape 7.

The whole examplefile:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JS</title>

</head>

<body bgcolor="#FFFFFF">

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

var px="px";

function getStyle(elemName) {
var elem;
if (document.getElemenetById) { 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=16+px;
style.height=16+px;
}
}

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

</script>

<br>
<br>
<div onMouseOver="showElement('test')" onMouseOut="hideElement('test')">
<a href="">Toggle</a>
</div>

<div id="test" style="position:absolute; z-index:1; left: 200px; top:
200px;">
Toogle this ....
</div>

</body>
</html>
Jul 20 '05 #5
"Ingmund Sjåstad" <in*****@sjaastad.no> writes:
I have now tried this, but it is still not working in Netscape 7.
As someone pointed out, there was a typo in a very significant place:
<script language="JavaScript" type="text/JavaScript">
language="JavaScript" is deprecated!
if (document.getElemenetById) { elem=document.getElementById(elemName);}


should be
if (document.getElementById) { elem=document.getElementById(elemName);}

If you change that, it works in my Mozilla Firebird.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6
DU
Ingmund Sjåstad wrote:
This scipt is working in IE6 but not in Netscape 7. What am I doin wrong?

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

var ns = false;
var ie = false;

ie = (document.all) ? true : false;
ns = (document.layers) ? true : false
function hideLayer(layerName) {
if (ie){
document.all(layerName).style.visibility="hidden";
document.all(layerName).style.width="16";
document.all(layerName).style.height="16";
} else if (ns) {
document.layers[layerName].visibility = "hide";
document.layers[layerName].width="16";
document.layers[layerName].height="16";
}
}

function showLayer(layerName) {
if (ie){
document.all(layerName).style.visibility="visible" ;
document.all(layerName).style.width="140";
document.all(layerName).style.height="400";
} else if (ns) {
document.layers[layerName].visibility = "show";
document.layers[layerName].width="140";
document.layers[layerName].height="400";
}
}

</script>
--

___________________________
Best Regards,

Ingmund Sjåstad
in*****@stadmek.no



These pages are precisely meeting your NS 4 and NS 7 difficulties.

Using Web Standards in Your Web Pages
http://www.mozilla.org/docs/web-deve...upgrade_2.html

Updating DHTML Web Pages
http://devedge.netscape.com/viewsour...tml-web-pages/

W3C markup validator
http://validator.w3.org/

Activating the Right Layout Mode Using the Doctype Declaration
http://www.hut.fi/u/hsivonen/doctype.html

Giving you the fishing techniques/resources/tools you need.

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

Jul 20 '05 #7
<html>
<head>
<title>Your title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name = "GENERATOR" Content = "ScrypTik V1.13">
<script type = "text/javascript" language = "Javascript">
<!-- Hide from older browsers;
function checkElement(getValue)
{
if(getValue == "MARC")
{
document.getElementById("td1").style.visibility="h idden";
document.getElementById("td2").style.visibility="h idden";
document.inputForm.HardwareType.value = "";
}
else if(getValue == "SONY")
{
document.getElementById("td1").style.visibility="v isible";
document.getElementById("td2").style.visibility="v isible";
}
}

// end hide -->
</script>
</head>
<body>
<!-- Insert HTML here -->
<FORM NAME="inputForm">
<TABLE border="2" >
<TR bgcolor="#FFFFFF" onMouseOut="this.bgColor='#FFFFFF';">
<TD>Node Type:</TD>
<TD>
<select name=nodeType onchange= "checkElement(this.value);">
<option value=" "> </option>
<option value="SONY">SONY</option>
<option value="MARC" > MARC</option>
<option value="RANI"> RANI</option>
</select>
</TD>
<TD><FONT color=blue>
Alias Name:
</FONT></TD>
<TD>
<input type=text name="aliasName" value="DOM5" size=25 maxlength=40>
</TD>
</TR>
<TR bgcolor="#FFFFFF" onMouseOut="this.bgColor='#FFFFFF';">
<TD id="td1">Hardware Type:</TD>
<TD id="td2">
<select name=HardwareType>
<option value=" " > </option>
<option value="SONY1" > SONY1</option>
<option value="SONY2" > SONY2</option>
</select>

</TD>
<TD><FONT color=blue>
IP Address:
</FONT></TD>
<TD>
<input type=text name="ipAddress" value="101.199.111.115" size=25 maxlength=40>
</TD>
</TR>
<TR bgcolor="#FFFFFF" onMouseOut="this.bgColor='#FFFFFF';">
<TD>
Managed:
</TD>
<TD>
<select name=managed>
<option value=""> </option>
<option value="true"> True</option>
<option value="false"> False</option>
</select>
</TD>
</TR>
</TABLE>
</body>
</html>

its working fine in IE and Netscape 8.1 but not working in Netscape 4.72, can anyone help me out........ plzzzzzzzzzz
Mar 1 '06 #8

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

Similar topics

1
by: Sims | last post by:
Hi, if i use... // php $info = getenv("HTTP_USER_AGENT"); // I noticed that Mozzila and Netscape <6(?) both use the same Agent. // so i was thinking of if...
1
by: mark.reichman | last post by:
First off.. Thanks to Grant Wagner for help in a previous thread related to this one. I am at a total loss... I have multiple fields in a form with the same name. Lets call the fields with the...
9
by: rez | last post by:
I find it rather frustrating that Netscape 4.x is "no longer supported:" http://help.netscape.com/products/client/communicator/reflib.html Same seems true with IE. How am I ever supposed to...
2
by: SabMan | last post by:
I understand that document.layers is no longer supported in Netscape 7.1 but I am not sure on how to fix the code so that it will work with Netscape 7.1. I understand that document.all is no...
26
by: Roger Desparois | last post by:
Hi, I need help : I found the simplest and most precise way to open and close submenu layers. it works perfectly with IE, but for some odd reason NS won't recognize it. Can anyone tell me why...
6
by: qqq | last post by:
I'm a relative newbie... I'd like my site to support Netscape browsers. For a page I set 'TargetSchema' to 'IE 3.02/Netscape 3'. When I insert label or textbox web controls on the page, they...
10
by: News | last post by:
I have a page up trying to learn how to ID a browser and other info. http://wyght.com/warren/testPos.html here is the code <script type = "text/javascript"> var space = ", "; var name...
4
by: Nathan Sokalski | last post by:
I was testing out a page of mine that displays the information from Page.Request.Browser. It works exactly as I expected in Internet Explorer and Netscape 4.75 (I didn't expect much in Netscape...
7
by: Joe | last post by:
I've been playing around with atlas for hte past couple days and its very impressive. However the standard browser here is Netscape, specifically: Netscape 7.02 Mozilla/5.0 (Windows; U; Windows NT...
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?
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...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.