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

L

lawrence

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.visibility='visible';
document.getElementById(nameOfDiv).style.height='auto';

if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.visibility='hidden';
if (nameOfDiv != 'entries')
document.getElementById('entries').style.visibility='hidden';
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.visibility='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.visibility='hidden';
if (nameOfDiv != 'links')
document.getElementById('links').style.visibility='hidden';
if (nameOfDiv != 'members')
document.getElementById('members').style.visibility='hidden';
if (nameOfDiv != 'design')
document.getElementById('design').style.visibility='hidden';
if (nameOfDiv != 'settings')
document.getElementById('settings').style.visibility='hidden';
if (nameOfDiv != 'categories')
document.getElementById('categories').style.visibility='hidden';
if (nameOfDiv != 'other')
document.getElementById('other').style.visibility='hidden';


if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.height='0px'
if (nameOfDiv != 'entries')
document.getElementById('entries').style.height='0px'
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.height='0px'
if (nameOfDiv != 'images')
document.getElementById('images').style.height='0px'
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='0px'
if (nameOfDiv != 'design')
document.getElementById('design').style.height='0px'
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.visibility='hidden';
document.getElementById('rightColumn').style.height='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/designer/mcControlPanel.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.
 
F

Fox

lawrence said:
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.visibility='visible';
document.getElementById(nameOfDiv).style.height='auto';

if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.visibility='hidden';
if (nameOfDiv != 'entries')
document.getElementById('entries').style.visibility='hidden';
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.visibility='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.visibility='hidden';
if (nameOfDiv != 'links')
document.getElementById('links').style.visibility='hidden';
if (nameOfDiv != 'members')
document.getElementById('members').style.visibility='hidden';
if (nameOfDiv != 'design')
document.getElementById('design').style.visibility='hidden';
if (nameOfDiv != 'settings')
document.getElementById('settings').style.visibility='hidden';
if (nameOfDiv != 'categories')
document.getElementById('categories').style.visibility='hidden';
if (nameOfDiv != 'other')
document.getElementById('other').style.visibility='hidden';


if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.height='0px'
if (nameOfDiv != 'entries')
document.getElementById('entries').style.height='0px'
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.height='0px'
if (nameOfDiv != 'images')
document.getElementById('images').style.height='0px'
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='0px'
if (nameOfDiv != 'design')
document.getElementById('design').style.height='0px'
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.visibility='hidden';
document.getElementById('rightColumn').style.height='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/designer/mcControlPanel.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...
 
L

lawrence

Fox said:
lawrence said:
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.visibility='visible';
document.getElementById(nameOfDiv).style.height='auto';

if (nameOfDiv != 'weblogs')
document.getElementById('weblogs').style.visibility='hidden';
if (nameOfDiv != 'entries')
document.getElementById('entries').style.visibility='hidden';
if (nameOfDiv != 'newsletters')
document.getElementById('newsletters').style.visibility='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.visibility='hidden';
if (nameOfDiv != 'links')
document.getElementById('links').style.visibility='hidden';
if (nameOfDiv != 'members')
document.getElementById('members').style.visibility='hidden';
if (nameOfDiv != 'design')
document.getElementById('design').style.visibility='hidden';
if (nameOfDiv != 'settings')
document.getElementById('settings').style.visibility='hidden';
if (nameOfDiv != 'categories')
document.getElementById('categories').style.visibility='hidden';
if (nameOfDiv != 'other')
document.getElementById('other').style.visibility='hidden';



document.getElementById('rightColumn').style.visibility='hidden';
document.getElementById('rightColumn').style.height='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?
 
F

Fox

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/manuals/2000/javascript/1.3/reference/ClientReferenceJS13.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/d...hor/dhtml/reference/dhtml_reference_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.]
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...
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top