473,799 Members | 3,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Netscape 7

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

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

var ns = false;
var ie = false;

ie = (document.all) ? true : false;
ns = (document.layer s) ? true : false
function hideLayer(layer Name) {
if (ie){
document.all(la yerName).style. visibility="hid den";
document.all(la yerName).style. width="16";
document.all(la yerName).style. height="16";
} else if (ns) {
document.layers[layerName].visibility = "hide";
document.layers[layerName].width="16";
document.layers[layerName].height="16";
}
}

function showLayer(layer Name) {
if (ie){
document.all(la yerName).style. visibility="vis ible";
document.all(la yerName).style. width="140";
document.all(la yerName).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 2406
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.layer s) ? true : false
document.all(la yerName).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.getEle mentById('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*****@sjaast ad.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(elemNa me) {
var elem;
if (document.getEl emenetById) { elem=document.g etElementById(e lemName);}


Spotted the deliberate mis^take !
else if (document.all) { elem=document.a ll[elemName];}
else if (document.layer s) { elem=document.l ayers[elemName]; px="";}
else {return null;}

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

function hideElement(ele mName) {
var style=getStyle( elemName);
if (style) {
style.visibilit y="hidden";
style.width=16+ px;
style.height=16 +px;
}
}

function showElement(ele mName) {
var style=getStyle( elemName);
if (style) {
style.visibilit y="visible";
style.width=140 +px;
style.height=40 0+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.getEl emenetById) { elem=document.g etElementById(e lemName);}
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="#FFFFF F">

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

var px="px";

function getStyle(elemNa me) {
var elem;
if (document.getEl emenetById) { elem=document.g etElementById(e lemName);}
else if (document.all) { elem=document.a ll[elemName];}
else if (document.layer s) { elem=document.l ayers[elemName]; px="";}
else {return null;}

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

function hideElement(ele mName) {
var style=getStyle( elemName);
if (style) {
style.visibilit y="hidden";
style.width=16+ px;
style.height=16 +px;
}
}

function showElement(ele mName) {
var style=getStyle( elemName);
if (style) {
style.visibilit y="visible";
style.width=140 +px;
style.height=40 0+px;
}
}

</script>

<br>
<br>
<div onMouseOver="sh owElement('test ')" onMouseOut="hid eElement('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*****@sjaast ad.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="JavaS cript" type="text/JavaScript">
language="JavaS cript" is deprecated!
if (document.getEl emenetById) { elem=document.g etElementById(e lemName);}


should be
if (document.getEl ementById) { elem=document.g etElementById(e lemName);}

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="JavaS cript" type="text/JavaScript">

var ns = false;
var ie = false;

ie = (document.all) ? true : false;
ns = (document.layer s) ? true : false
function hideLayer(layer Name) {
if (ie){
document.all(la yerName).style. visibility="hid den";
document.all(la yerName).style. width="16";
document.all(la yerName).style. height="16";
} else if (ns) {
document.layers[layerName].visibility = "hide";
document.layers[layerName].width="16";
document.layers[layerName].height="16";
}
}

function showLayer(layer Name) {
if (ie){
document.all(la yerName).style. visibility="vis ible";
document.all(la yerName).style. width="140";
document.all(la yerName).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
marcia_pippin
1 New Member
<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(ge tValue)
{
if(getValue == "MARC")
{
document.getEle mentById("td1") .style.visibili ty="hidden";
document.getEle mentById("td2") .style.visibili ty="hidden";
document.inputF orm.HardwareTyp e.value = "";
}
else if(getValue == "SONY")
{
document.getEle mentById("td1") .style.visibili ty="visible";
document.getEle mentById("td2") .style.visibili ty="visible";
}
}

// end hide -->
</script>
</head>
<body>
<!-- Insert HTML here -->
<FORM NAME="inputForm ">
<TABLE border="2" >
<TR bgcolor="#FFFFF F" onMouseOut="thi s.bgColor='#FFF FFF';">
<TD>Node Type:</TD>
<TD>
<select name=nodeType onchange= "checkElement(t his.value);">
<option value=" "> </option>
<option value="SONY">SO NY</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="#FFFFF F" onMouseOut="thi s.bgColor='#FFF FFF';">
<TD id="td1">Hardwa re Type:</TD>
<TD id="td2">
<select name=HardwareTy pe>
<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="#FFFFF F" onMouseOut="thi s.bgColor='#FFF FFF';">
<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
5037
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 (preg_match("/Mozilla/i", $info)) {
1
9594
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 same name "junk_array". My first field of junk_array is a input type=hidden. All the others fields in junk_array that follow are type=text. I can reference this first hidden field in IE with document.form.field.value. In, fact my form works...
9
2559
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 make my scripts multi-browser, when they don't bother giving me basic documentation?
2
2200
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 longer supported in IE6 but I am not sure on how to fix the code so that it will work with IE6. <!--
26
2208
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 ? And is there a way around the problem ?
6
1915
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 appear with no size/color/border attributes etc. when viewed in Netscape. They appear just fine in IE. Can someone please explain? Thanks - Paul.
10
2377
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 = navigator.appName;
4
1837
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 4.75, but I got some stuff). However, Netscape 7.1 gave me some strange stuff, including the following: 1. It gave the Version as 5.0 rather than 7.1, and the Type as Netscape5 2. ASP.NET did not send any CSS other than the constant part that I...
7
1616
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 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 While everythign works great in Firefox and IE, absolutely nothing seems to work with netscape. Is there something I need to change in my browser caps to get it to work in netscape? I want to...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.