473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A problem with an apparently common JS menu...

I am attempting to make a web page more Netscape friendly... <a
href="http:www. gordonceilings. com"></a>

I have already corrected the table issues in an offline staging site
(where I do the building and then move it to the live site when ready),
so don't worry about those. My problem lies in the menu on the left. It
shows up and the initial links work in Netscape 8, but the menu will
not drop down to show the sub-selections. I can get the sub-menus to
drop down with "document.getEl ementById" arguments, but the rest of the
menu won't move down accordingly to make room, making for a jumbled
mess. It works flawlessly in IE5 and 6 with either document.all or
getElementById, but in looking for an answer I see that IE is more
forgiving...

Here is the script, it seems to be a common one:

<SCRIPT LANGUAGE="JavaS cript">

// ADDITIONAL NOTES
// The input variables to the toggle function are the number of the
submenu to open/close,
// starting with 0, and the number of pixels to move the objects below.
// For example toggle(1,60) opens/closes the second submenu and moves
the objects below 60 pixels.

var nom = 10; // Number of menus
var usePictures = 0; // use pictures? 1 = yes, 0 = no

var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;

if (document.layer s) {
visible = 'show';
hidden = 'hide';
}
else
if (document.all) {
visible = 'visible';
hidden = 'hidden';
}
for (var i = 1; i <= nom; i++) {
ttls[i] = ('title' + i);
subs[i] = ('submenu' +i);
}
function picopen(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.layer s) {
document.layers[title].document.image s[pic].src = "opened.gif ";
}
else if (document.all) {
document.all(pi c).src = "opened.gif ";
}
}
function picclose(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.layer s) {
document.layers[title].document.image s[pic].src = "closed.gif ";
}
else if (document.all) {
document.all(pi c).src = "closed.gif ";
}
}
lastn = (nom + 1);
lastmove = 0;
function lasttoggle(n,mo ve) {
if (n <= nom) {
menu = ('submenu' + n);
if (document.layer s) {
submenu = document.layers[menu];
}
else if (document.all) {
submenu = document.all(me nu).style;
}
if (submenu.visibi lity == visible) {
submenu.visibil ity = hidden;
for (var i = (n+1); i <= nom; i++) {
if (document.layer s) {
document.layers[ttls[i]].top -= move;
document.layers[subs[i]].top -= move;
}
else if (document.all) {
document.all(tt ls[i]).style.pixelTo p -= move;
document.all(su bs[i]).style.pixelTo p -= move;
}
}
}
}
}
function toggle(n,move) {
menu = ('submenu' + n);
if (document.layer s) {
submenu = document.layers[menu];
}
else if (document.all) {
submenu = document.all(me nu).style;
}
if (submenu.visibi lity == visible) {
submenu.visibil ity = hidden;
if (usePictures) picclose(n);
for (var i = (n+1); i <= nom; i++) {
if (document.layer s) {
document.layers[ttls[i]].top -= move;
document.layers[subs[i]].top -= move;
}
else if (document.all) {
document.all(tt ls[i]).style.pixelTo p -= move;
document.all(su bs[i]).style.pixelTo p -= move;
}
}
}
else {
submenu.visibil ity = visible;
if (usePictures) picopen(n);
if (lastn != n) {
lasttoggle(last n,lastmove);
}
for (var i = (n+1); i <= nom; i++) {
if (document.layer s) {
document.layers[ttls[i]].top += move;
document.layers[subs[i]].top += move;
}
if (document.all) {
document.all(tt ls[i]).style.pixelTo p += move;
document.all(su bs[i]).style.pixelTo p += move;
}
}
}
lastn = n;
lastmove = move;
}
function loadFrames(fram e1,page1) {
eval("parent."+ frame1+".locati on='"+page1+"'" );
}
// End -->

</script>

So far all I can find concerning this script is people that are having
problems with it... maybe it's time for a new script, but I really
don't want to have to rebuild the menu...

Nov 23 '05 #1
14 1937
Oh yeah, you need to click on the Gordon Interior Specialties logo on
the entrance page... the one with the red G...

Nov 23 '05 #2
Bryan wrote:
if (document.layer s) {
if (document.all) { maybe it's time for a new script


Lots of document.layers (NS4.x only) and lots of document.all (IE4 only[1]),
but not a lot of W3C DOM. It was time for a new script several years ago.

[1] Other browsers do support it, although I seem to recall that only IE
returns true if you test for it, other browsers assume that if you are
smart enough to test for support, then you are smart enough to use the W3C
DOM.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Nov 23 '05 #3
Like I said, I can get the menus to appear in Netscape using
"document.getEl ementById" instead of "document.a ll", but the rest of
the menu won't drop down to accommodate it. Everything I'm seeing tells
me to use "document.getEl ementById", and I do, but nothing tells me how
to make the menu move for the visible layer.

Are the "document.layer s" entries necessary? Maybe they're
interfering...

Nov 23 '05 #4
OK, I have set up the menu like so:

<SCRIPT LANGUAGE="JavaS cript">

// ADDITIONAL NOTES
// The input variables to the toggle function are the number of the
submenu to open/close,
// starting with 0, and the number of pixels to move the objects below.
// For example toggle(1,60) opens/closes the second submenu and moves
the objects below 60 pixels.

var nom = 10; // Number of menus
var usePictures = 0; // use pictures? 1 = yes, 0 = no

var ttls = new Array(); // An array for the title objects
var subs = new Array(); // An array for the submenu objects
var lastn;
var lastmove;

if (document.getEl ementById) {
visible = 'visible';
hidden = 'hidden';
}
for (var i = 1; i <= nom; i++) {
ttls[i] = ('title' + i);
subs[i] = ('submenu' +i);
}
function picopen(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.getEl ementById) {
document.getEle mentById(pic).s rc = "opened.gif ";
}
}
function picclose(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.getEl ementById) {
document.getEle mentById(pic).s rc = "closed.gif ";
}
}
lastn = (nom + 1);
lastmove = 0;
function lasttoggle(n,mo ve) {
if (n <= nom) {
menu = ('submenu' + n);
if (document.getEl ementById) {
submenu = document.getEle mentById(menu). style;
}
if (submenu.visibi lity == visible) {
submenu.visibil ity = hidden;
for (var i = (n+1); i <= nom; i++) {
if (document.getEl ementById) {
document.getEle mentById(ttls[i]).style.pixelTo p -= move;
document.getEle mentById(subs[i]).style.pixelTo p -= move;
}
}
}
}
}
function toggle(n,move) {
menu = ('submenu' + n);
if (document.getEl ementById) {
submenu = document.getEle mentById(menu). style;
}
if (submenu.visibi lity == visible) {
submenu.visibil ity = hidden;
if (usePictures) picclose(n);
for (var i = (n+1); i <= nom; i++) {
if (document.getEl ementById) {
document.getEle mentById(ttls[i]).style.pixelTo p -= move;
document.getEle mentById(subs[i]).style.pixelTo p -= move;
}
}
}
else {
submenu.visibil ity = visible;
if (usePictures) picopen(n);
if (lastn != n) {
lasttoggle(last n,lastmove);
}
for (var i = (n+1); i <= nom; i++) {
if (document.getEl ementById) {
document.getEle mentById(ttls[i]).style.pixelTo p += move;
document.getEle mentById(subs[i]).style.pixelTo p += move;
}
}
}
lastn = n;
lastmove = move;
}
function loadFrames(fram e1,page1) {
eval("parent."+ frame1+".locati on='"+page1+"'" );
}
// End -->

</script>

The drop downs works, but I have the problem of the menu not making
room... maybe I'm barking up the wrong tree, so here's and example of
the code for one of the submenus:

<div class="title" id="title3" style="top: 40px;">
<a href="alumavaul t/index.html" Target=main onclick="javasc ript:
toggle(3,80); loadFrames('mai n', 'alumavault/index.html'); return
false">
Curved Metal Ceilings</a>
</div>

<div class="submenu" id="submenu3" style="top: 55px; height:48">
<a href="alumavaul t/av1000.html" target="main">S ystem
1000/2000</a><br>
<a href="alumavaul t/av3000.html" target="main">S ystem 3000</a><br>
<a href="alumavaul t/perimeters.html " target="main">P erimeters</a><br>
<a href="alumavaul t/options.html" target="main">O ptions</a><br>
<a href="alumavaul t/details.htm" target="main">P roduct Data</a><br>
<a href="Galleryba ckup/gallery.htm#cur ved metal ceilings"
target="main">G allery</a>
</div>
Basically, the beginning part is supposed to toggle the menu a specific
number of pixels... so if the menu isn't toggling, maybe the JS isn't
the problem, but the submenu code...

Nov 23 '05 #5
VK

Bryan wrote:
Like I said, I can get the menus to appear in Netscape using
"document.getEl ementById" instead of "document.a ll", but the rest of
the menu won't drop down to accommodate it. Everything I'm seeing tells
me to use "document.getEl ementById", and I do, but nothing tells me how
to make the menu move for the visible layer.

Are the "document.layer s" entries necessary? Maybe they're
interfering...


Yes they are (besides other things). This is an ancient wartime script
for Netscape 4.x (document.layer s) and Internet Explorer (document.all)

Netscape 4.x is gone, but as a reminder document.layers are still
supported (or at least do not return undefined > false) on some
browsers, for example Netscape (what a surprise!) or Safari.

Netscape 8.x adds even more spice in this picture because it operates
in so-called dual mode: depending on the page/script details it uses
either Gesko engine or Internet Explorer engine. As your ... if
(document.layer s)... check comes before ...(document.al l)... check -
the results may be really interesting but definitely not the expected
ones.

Internet Explorer still supports document.all collection so it works.
But all modern desktop browsers support document.getEle mentById method
including Internet Explorer.

It is really easier to right a new script from the scratch (will be
much less typing to do). But if you want to base on this code then:

1. Remove all "if (document.layer s) {...}" branches completely
2. Replace all "else if (document.all)" with "if
(document.getEl ementById)"
3. Go through the text and replace all "document.a ll(" strings with
"document.getEl ementById("
4. Save and test.

Nov 23 '05 #6
Bryan wrote:
<SCRIPT LANGUAGE="JavaS cript">
[...]
else if (document.all) {
document.all(tt ls[i]).style.pixelTo p -= move;
document.all(su bs[i]).style.pixelTo p -= move;
[...]
function loadFrames(fram e1,page1) {
eval("parent."+ frame1+".locati on='"+page1+"'" );
}
// End -->
[...]
</script>

So far all I can find concerning this script is people that are having
problems with it... maybe it's time for a new script, but I really
don't want to have to rebuild the menu...


Invalid markup, insufficient feature tests, proprietary referencing,
evil[tm] eval(), and nonsensical, potential harmful comments (in that
order) ... what do you expect?

<http://jibbering.com/faq/>
PointedEars
Nov 23 '05 #7
>>Invalid markup, insufficient feature tests, proprietary referencing,
evil[tm] eval(), and nonsensical, potential harmful comments (in that
order) ... what do you expect?


If I knew, I wouldn't need to ask... :P

I removed all comments, got rid of eval, now I just need to know what
part of the markup is invalid, what is "proprietar y referencing", and
what feature tests I should run...

It still runs perfectly in IE, but the menu doesn't budge in Netscape
when the submenu is made visible...

Code now looks like:

<SCRIPT LANGUAGE="JavaS cript">

var nom = 10;
var usePictures = 0;

var ttls = new Array();
var subs = new Array();
var lastn;
var lastmove;

if (document.getEl ementById) {
visible = 'visible';
hidden = 'hidden';
}
for (var i = 1; i <= nom; i++) {
ttls[i] = ('title' + i);
subs[i] = ('submenu' +i);
}
function picopen(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.getEl ementById) {
document.getEle mentById(pic).s rc = "opened.gif ";
}
}
function picclose(n) {
title = ('title' + n);
pic = ('pic' + n);
if (document.getEl ementById) {
document.getEle mentById(pic).s rc = "closed.gif ";
}
}
lastn = (nom + 1);
lastmove = 0;
function lasttoggle(n,mo ve) {
if (n <= nom) {
menu = ('submenu' + n);
if (document.getEl ementById) {
submenu = document.getEle mentById(menu). style;
}
if (submenu.visibi lity == visible) {
submenu.visibil ity = hidden;
for (var i = (n+1); i <= nom; i++) {
if (document.getEl ementById) {
document.getEle mentById(ttls[i]).style.pixelTo p -= move;
document.getEle mentById(subs[i]).style.pixelTo p -= move;
}
}
}
}
}
function toggle(n,move) {
menu = ('submenu' + n);
if (document.getEl ementById) {
submenu = document.getEle mentById(menu). style;
}
if (submenu.visibi lity == visible) {
submenu.visibil ity = hidden;
if (usePictures) picclose(n);
for (var i = (n+1); i <= nom; i++) {
if (document.getEl ementById) {
document.getEle mentById(ttls[i]).style.pixelTo p -= move;
document.getEle mentById(subs[i]).style.pixelTo p -= move;
}
}
}
else {
submenu.visibil ity = visible;
if (usePictures) picopen(n);
if (lastn != n) {
lasttoggle(last n,lastmove);
}
for (var i = (n+1); i <= nom; i++) {
if (document.getEl ementById) {
document.getEle mentById(ttls[i]).style.pixelTo p += move;
document.getEle mentById(subs[i]).style.pixelTo p += move;
}
}
}
lastn = n;
lastmove = move;
}

// End -->

</script>

Nov 23 '05 #8
Bryan wrote:
Invalid markup, insufficient feature tests, proprietary referencing,
evil[tm] eval(), and nonsensical, potential harmful comments (in that
order) ... what do you expect?

If I knew, I wouldn't need to ask... :P


If you knew, you would throw it away. One important question just
occured to me: Does your "JS menu" still work if there is no JS support,
i.e. can one still navigate then? If not, you have certainly bigger
problems than a not-working script.
I removed all comments, got rid of eval, now I just need to know what
part of the markup is invalid,
<http://validator.w3.or g/> will tell you, trust me.
what is "proprietar y referencing", and
In contrast to `document.getEl ementById', `document.all' is not a
reference to an Function object, so it is inappropriate to refer
to its members by using the Call Operator (`()'). While the IE DOM
allows both document.all[...] and document.all(.. .) to refer to
members of this collection, this is certainly not standards compliant
behavior and therefore error-prone (MS may recognize this bug and
remove it in future IE versions with you having to deal with the
consequences): the same property cannot be both non-function and
function.
what feature tests I should run...
Opera also supports `document.all' for a targeted, yet failed,
compatibility to IE (for reasons that elude me), but does not provide
the same feature set as IE does. When it comes to AOM/DOM, you should
to test for all possible incompatible features you use, else you risk
(the user receiving) script errors.
It still runs perfectly in IE, [...]


Of course. To put in bluntly, IE can make gold out of the worst junk.
That is good for users in the short-term because they do not have to
deal with the results of the work of incompetent authors. It is bad
for both the user and the authors in the mid-term because average code
quality decreases and Web sites become less interoperable, while users
and therefore authors become dependent on the products and mercy of
one single vendor -- Micro$~1 Corp.
PointedEars

P.S.
Please learn how to quote properly:
<http://jibbering.com/faq/faq_notes/pots1.html> pp.
Nov 23 '05 #9
Thomas 'PointedEars' Lahn <Po*********@we b.de> writes:
In contrast to `document.getEl ementById', `document.all' is not a
reference to an Function object, so it is inappropriate to refer
to its members by using the Call Operator (`()').
Since the only official specification of document.all is the MSDN
<URL:http://msdn.microsoft. com/workshop/author/dhtml/reference/collections/all.asp>
and it uses function call as the access method, I don't think you
can say that it isn't. It's untraditional to use function objects
for collections, but not illegal in any way.
While the IE DOM allows both document.all[...] and document.all(.. .)
to refer to members of this collection, this is certainly not
standards compliant behavior
It can't be, since there is no standard. The document.all
functionality is very much a de-facto standard of "doing like IE
does".
and therefore error-prone (MS may recognize this bug and remove it
in future IE versions with you having to deal with the
consequences):
Unlikely. At times I wish they would forget about backwards
compatability and do things right instead, but it's not the way they
work.
the same property cannot be both non-function and function.


Then it's a function (i.e., an object with a [[Call]] method).
Functions are objects, so it's not impossible to have properties
that work with the property access operator at the same time.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Nov 23 '05 #10

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

Similar topics

3
2468
by: bill drescher | last post by:
The menu at: http://www.alsacreations.com/articles/deroulant/cssmenu.htm does exactly what I want, except: If you leave a menu (and submenu) by going _down_ to the next menu the first does not close. If you exit the menu to the right side it does. Is this a Mozilla bug (1.5) , or a desired effect of the css ? IF neither, how can I make the menu close when I leave the submenu on the bottom ? --
10
3487
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What is wrong with my link? I'd
10
3111
by: H.S. | last post by:
Hi, Let me begin by saying that I am not an HTML expert. The most experience I have for HTML authoring is when I made my webpages in my grad studies at my university and some on my home computer for experiments. I am however familiar with programming languages and am quite familiar with Linux (use Debian Testing). I am in the process of revamping my old old old webpage. I have decided not to use frames for now and try to made do...
8
1546
by: RCS | last post by:
All, OK, so I'm working on a template for our new ASP.NET applications. Part of this, includes using the new menu and breadcrumbs control in ASP.NET 2.0 (I'm using beta 2). I put the hierarchy of the applications and navigation in a database, and am able to pull that into the app by inheriting StaticSiteMapProvider. So that's set and works great.
17
1838
by: John Bailo | last post by:
What does he do all day? Find out here: http://channel9.msdn.com/Showpost.aspx?postid=163166
0
1500
by: john_mcmahon | last post by:
I'm having issues populating a second drop down menu that's dependent upon a selection in the first menu. When I select an option from the first menu, the second menu remains disabled, i.e. unable to select an option. I'm confident that most of my code is correct because of testing that I completed with it. For instance, when I remove the ParentControlID attribute from the second control and un-comment out: // string sPlantTypeID = "2";...
1
1719
by: rfr | last post by:
Apparently the Transitional Doctype kills this script because the script does not make proper use of units like "px". It works well without a doctype statement. But once someone adds a transitional doctype, the js script no longer works. Can someone familiar with javascript bring it up-to-date so that it works with current doctypes and post it here for others to make use of? The whole HTML document including the js scrip follows (...
0
2195
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into problems later). Apparently Point is a struct, a value type, and it does not behave like a classic structure (in my mind's eye, and see below). Traditionally I think of a classic structure as simply an object where every member is public. But with...
5
13381
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9641
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
9480
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
10146
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...
1
10080
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.