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

Code works in Netscape 7.1 but not IE ---- document.getElementById('other').style.visibility= 'hidden';

P: n/a
Can anyone tell me why this code works in Netscape 7.1 but not in
IE???
<SCRIPT type='text/javascript'>
function makeVisible(nameOfDiv) {
document.getElementById(nameOfDiv).style.visibilit y='visible';
document.getElementById(nameOfDiv).style.height='a uto';

if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.visibilit y='hidden';
if (nameOfDiv != 'entries')
document.getElementById('entries').style.visibilit y='hidden';
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.visib ility='hidden';
if (nameOfDiv != 'images')
document.getElementById('images').style.visibility ='hidden';
if (nameOfDiv != 'files')
document.getElementById('files').style.visibility= 'hidden';
if (nameOfDiv != 'comments')
document.getElementById('comments').style.visibili ty='hidden';
if (nameOfDiv != 'links')
document.getElementById('links').style.visibility= 'hidden';
if (nameOfDiv != 'members')
document.getElementById('members').style.visibilit y='hidden';
if (nameOfDiv != 'design')
document.getElementById('design').style.visibility ='hidden';
if (nameOfDiv != 'settings')
document.getElementById('settings').style.visibili ty='hidden';
if (nameOfDiv != 'categories')
document.getElementById('categories').style.visibi lity='hidden';
if (nameOfDiv != 'other')
document.getElementById('other').style.visibility= 'hidden';
if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.height='0 px'
if (nameOfDiv != 'entries')
document.getElementById('entries').style.height='0 px'
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.heigh t='0px'
if (nameOfDiv != 'images')
document.getElementById('images').style.height='0p x'
if (nameOfDiv != 'files')
document.getElementById('files').style.height='0px '
if (nameOfDiv != 'comments')
document.getElementById('comments').style.height=' 0px'
if (nameOfDiv != 'links')
document.getElementById('links').style.height='0px '
if (nameOfDiv != 'members')
document.getElementById('members').style.height='0 px'
if (nameOfDiv != 'design')
document.getElementById('design').style.height='0p x'
if (nameOfDiv != 'settings')
document.getElementById('settings').style.height=' 0px'
if (nameOfDiv != 'categories')
document.getElementById('categories').style.height ='0px'
if (nameOfDiv != 'other')
document.getElementById('other').style.height='0px '

document.getElementById('rightColumn').style.visib ility='hidden';
document.getElementById('rightColumn').style.heigh t='0px';

}
</script>
There are some other problems with the page, and I'm trying to fix
them one at time. Perhaps I'm fixing them in the wrong order. To see
the page, go here:

http://publicdomainsoftware.org/desi...ntrolPanel.php
You'll need a username and password to log in, so use these values:

username: designer
password: designer123

Clicking on an image is supposed to make the DIVs in the middle
visible. This works in Netscape but not IE.
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Fox
lawrence wrote:
Can anyone tell me why this code works in Netscape 7.1 but not in
IE???
<SCRIPT type='text/javascript'>
function makeVisible(nameOfDiv) {
document.getElementById(nameOfDiv).style.visibilit y='visible';
document.getElementById(nameOfDiv).style.height='a uto';

if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.visibilit y='hidden';
if (nameOfDiv != 'entries')
document.getElementById('entries').style.visibilit y='hidden';
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.visib ility='hidden';
if (nameOfDiv != 'images')
document.getElementById('images').style.visibility ='hidden';
if (nameOfDiv != 'files')
document.getElementById('files').style.visibility= 'hidden';
if (nameOfDiv != 'comments')
document.getElementById('comments').style.visibili ty='hidden';
if (nameOfDiv != 'links')
document.getElementById('links').style.visibility= 'hidden';
if (nameOfDiv != 'members')
document.getElementById('members').style.visibilit y='hidden';
if (nameOfDiv != 'design')
document.getElementById('design').style.visibility ='hidden';
if (nameOfDiv != 'settings')
document.getElementById('settings').style.visibili ty='hidden';
if (nameOfDiv != 'categories')
document.getElementById('categories').style.visibi lity='hidden';
if (nameOfDiv != 'other')
document.getElementById('other').style.visibility= 'hidden';
if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.height='0 px'
if (nameOfDiv != 'entries')
document.getElementById('entries').style.height='0 px'
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.heigh t='0px'
if (nameOfDiv != 'images')
document.getElementById('images').style.height='0p x'
if (nameOfDiv != 'files')
document.getElementById('files').style.height='0px '
if (nameOfDiv != 'comments')
document.getElementById('comments').style.height=' 0px'
if (nameOfDiv != 'links')
document.getElementById('links').style.height='0px '
if (nameOfDiv != 'members')
document.getElementById('members').style.height='0 px'
if (nameOfDiv != 'design')
document.getElementById('design').style.height='0p x'
if (nameOfDiv != 'settings')
document.getElementById('settings').style.height=' 0px'
if (nameOfDiv != 'categories')
document.getElementById('categories').style.height ='0px'
if (nameOfDiv != 'other')
document.getElementById('other').style.height='0px '

document.getElementById('rightColumn').style.visib ility='hidden';
document.getElementById('rightColumn').style.heigh t='0px';

}
</script>
There are some other problems with the page, and I'm trying to fix
them one at time. Perhaps I'm fixing them in the wrong order. To see
the page, go here:

http://publicdomainsoftware.org/desi...ntrolPanel.php
You'll need a username and password to log in, so use these values:

username: designer
password: designer123

Clicking on an image is supposed to make the DIVs in the middle
visible. This works in Netscape but not IE.


The above code *should* work fine... the problem seems to be your body
tag -- you have two event handlers referenced [onload="scrolltop()"
onunload="stoptimer()"] and nowhere do they seem to be declared... IE
will stop executing scripts with those kinds of errors. BTW -- these two
errors appear in the JavaScript Console in Netscape/Mozilla apps as
Error: functionName is not defined.

declare the functions (even if they are empty for now):
(e.g.:)
function
scrollTop()
{
}

.... or remove the handler references.

You can find the JavaScript Console under the Tools menu...
Jul 23 '05 #2

P: n/a
> Can anyone tell me why this code works in Netscape 7.1 but not in IE???

try these two changes, this works on my IE6:

#weblogs ,#entries ,#newsletters , #images ,#files ,#comments,
#links,#members ,#design, #settings ,#categories,#other {
top: 100px;
left: 250px;
position: absolute;
height:0px;
visibility:hidden;
background-color:#fffdfd;
padding:8px;
width:475px;
float:right;
}

<SCRIPT type='text/javascript'>
var arrNames=new
Array('weblogs','entries','newsletters','images',' files','comments','links','members','design','sett ings','categories','other','rightColumn');
var divname;
function makeVisible(nameOfDiv) {
for (var i=0; i<arrNames.length;i++) {
divname=document.getElementById(arrNames[i]);
if (nameOfDiv == arrNames[i]) {
divname.style.visibility='visible';
} else {
divname.style.visibility='hidden';
}
}
}
</script>

Mike
Jul 23 '05 #3

P: n/a
Fox <fo*@fxmahoney.com> wrote in message news:<cj**********@news.datasync.com>...
lawrence wrote:
Can anyone tell me why this code works in Netscape 7.1 but not in
IE???
<SCRIPT type='text/javascript'>
function makeVisible(nameOfDiv) {
document.getElementById(nameOfDiv).style.visibilit y='visible';
document.getElementById(nameOfDiv).style.height='a uto';

if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.visibilit y='hidden';
if (nameOfDiv != 'entries')
document.getElementById('entries').style.visibilit y='hidden';
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.visib ility='hidden';
if (nameOfDiv != 'images')
document.getElementById('images').style.visibility ='hidden';
if (nameOfDiv != 'files')
document.getElementById('files').style.visibility= 'hidden';
if (nameOfDiv != 'comments')
document.getElementById('comments').style.visibili ty='hidden';
if (nameOfDiv != 'links')
document.getElementById('links').style.visibility= 'hidden';
if (nameOfDiv != 'members')
document.getElementById('members').style.visibilit y='hidden';
if (nameOfDiv != 'design')
document.getElementById('design').style.visibility ='hidden';
if (nameOfDiv != 'settings')
document.getElementById('settings').style.visibili ty='hidden';
if (nameOfDiv != 'categories')
document.getElementById('categories').style.visibi lity='hidden';
if (nameOfDiv != 'other')
document.getElementById('other').style.visibility= 'hidden';

document.getElementById('rightColumn').style.visib ility='hidden';
document.getElementById('rightColumn').style.heigh t='0px';

}
</script>
The above code *should* work fine... the problem seems to be your body
tag -- you have two event handlers referenced [onload="scrolltop()"
onunload="stoptimer()"] and nowhere do they seem to be declared... IE
will stop executing scripts with those kinds of errors.


Nice to know. Those are two functions that played a role in the old
design but are useless in the new design.

On another subject, where do you learn all this stuff? I'm wondering
where I can find out stuff like this, other than newsgroups. In
particular, cross-browser stuff seems tough to glean from the
reference material, which tends to talk about EMCAscript as a
stand-alone ideal, or talks about how any particular browser does
things.


BTW -- these two
errors appear in the JavaScript Console in Netscape/Mozilla apps as
Error: functionName is not defined.

declare the functions (even if they are empty for now):
(e.g.:)
function
scrollTop()
{
}

... or remove the handler references.

I'll remove the handler references.
But let me get philosophical for a momement. Javascript is a script
language. It's suppose to break with maximum grace, yes? It isn't
Java, one isn't expecting strong typing or a maximum of rule
enforcement. So why does IE die on an error like this? Why not just
throw a warning and move on? Given the environment it works in, I'd
think there would be premium on allowing a script to work if at all
possible. What is Microsoft's reasoning here?
Jul 23 '05 #4

P: n/a
Fox
lawrence wrote:
<shortened>
Nice to know. Those are two functions that played a role in the old
design but are useless in the new design.

On another subject, where do you learn all this stuff? I'm wondering
where I can find out stuff like this, other than newsgroups. In
particular, cross-browser stuff seems tough to glean from the
reference material, which tends to talk about EMCAscript as a
stand-alone ideal, or talks about how any particular browser does
things.
ECMAScript is a nice idea, and it has gone a long way in standardizing
the language (and to some extent, stunting it as well), but JScript and
JavaScript have managed to keep certain aspects of their respective
languages "proprietary" -- so there is a "core" JavaScript/JScript that
are ECMA compliant and there are extra features to both that are
exclusive to each (most documentation will tell you which parts are ECMA
compliant). They are, roughly, about 95% (or better) compatible. It's
when you start interacting with other parts of the environment that are
"exposed" to JS that things "get interesting." On the upside:
cross-browser issues seem to have considerably lessened in the last
couple of years.

There is plenty in the way of online documentation for dealing with
various scripting languages and DOMs...

For JavaScript, I live by this:

http://devedge.netscape.com/library/...erenceJS13.zip
This is NOT the latest information, but it is the one that is the best
presentation -- you can go back for the JS1.5 reference as an addendum.
Download it and install it in a convenient location -- Bookmark the index...

The corresponding guide is okay -- but mostly unused -- you'll probably
never need it.

For a DOM reference, I like:

http://msdn.microsoft.com/library/de...ence_entry.asp
for best results, you should probably view this site in IE6 if you're
using a PC. If you navigate around, you'll find Scripting (->JScript)
documentation there as well (but it's generally pretty bad.)

If after these two, I run into trouble with mozilla, I'll go to the source:
http://www.mozilla.org/catalog/web-developer/
or
http://www.mozilla.org/docs/dom/domref/

I occasionally will shortcut through all of this by checking:
http://javascript.faqts.com first... A lot of questions have been
answered there and it's fairly easily searched [plus, under the
Documentation column, there are many links like the ones I've referenced
for you available there.]



BTW -- these two
errors appear in the JavaScript Console in Netscape/Mozilla apps as
Error: functionName is not defined.

declare the functions (even if they are empty for now):
(e.g.:)
function
scrollTop()
{
}

... or remove the handler references.
I'll remove the handler references.
But let me get philosophical for a momement. Javascript is a script
language. It's suppose to break with maximum grace, yes? It isn't
Java, one isn't expecting strong typing or a maximum of rule
enforcement. So why does IE die on an error like this?


[guessing:] I'd have to say because they are event handlers... IE
doesn't usually stop executing scripts for relatively minor errors.
Technically, IE does not "die" with this, it just stops executing your
scripts... or parts of your scripts... You can't really "nail" IE with
this one, mozilla will do some pretty weird things sometimes with a
messed up script [like things will work up to a point, then whole layers
will just disappear!!!]. The point is: if there is an error in the
script, it needs to be fixed. It's actually "poor form" to release a
page to the public with errors on it... especially if it's IE (the
majority) since it's plainly visible from the front of the browser that
there are problems with a script.

[*you'll see a small yellow triangle icon in the lower left corner of
the browser with "Error on Page" in the status bar when there is an
error on the page -- double clicking on it will give you the line number
of the error and some arcane message like "Object expected" (big help
<sarcasm>)-- you can usually figure out what the problem is inpecting
the code where the error occurs. Unfortunately, IE's reporting can be
"off" from your source code, so what I usually do is View Source, then
copy and paste the code as "IE sees it" and then track down the line
number of the error (this seems to work in most cases -- find an editor
that displays line numbers like Crimson Editor or similar) -- otherwise,
use Netscape's(/mozilla's) JavaScript Console] Why not just throw a warning and move on? Given the environment it works in, I'd
think there would be premium on allowing a script to work if at all
possible.
I think you can change a couple of settings in Tools -> Internet Options
[Advanced] [] Disable Script debugging and/or [] Display a notification
about every script error -- you'll want to uncheck the first one and
check the second.
What is Microsoft's reasoning here?

I'll venture a guess that it has to do with *their* idea of your
convenience.

I mess around with my settings every so often, so I don't remember if
the debugging settings are default, or something I chose to deselect...I
find the script error notification to be truly annoying when surfing...
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.